Can someone please help me out?

Write an expression that multiplies the length of a room by the width (to calculate the area) and assign the result to a variable that represents the area.

I can't figure this out, i would appreciate it if someone could explain this to me and write the program for me, thanks.

Re: Can someone please help me out?

Quote:

Originally Posted by

**coolkid456** Write an expression that multiplies the length of a room by the width (to calculate the area) and assign the result to a variable that represents the area.

I can't figure this out, i would appreciate it if someone could explain this to me and write the program for me, thanks.

That's not how it works here. We'll be happy to try to help you, but we bristle when someone asks us to write a program for them or do their homework for them. So please show us what you've done so far, please ask specific questions, and let's see how we can clear up any confusions for you and try to help you out.

Re: Can someone please help me out?

Re: Can someone please help me out?

String strLength, strHeight;

double dblLength, dblHeight, dblArea;

strLength = JOptionPane.showInputDialog ( “Enter the room’s length: “);

strBase = JOptionPane.showInputDialog ( “Enter the room’s base: ”);

this is what I've have so far, what do you think?

Re: Can someone please help me out?

The assignment as posted asks for an "expression". To me that suggests that they want a single line of code, and that they assume that length and area have already been obtained. If so, then I'd create a single line of code that does the necessary multiplication and assigns the result to a variable that is supposed to hold the area.

I may be wrong as I have not seen the entire assignment, but just based on your initial post, that appears all that is expected here.

Re: Can someone please help me out?

I'm not sure if this is what the question is asking me to do.

Re: Can someone please help me out?

Ok so i don't need to do all that stuff, all i need to do is dblArea = dbLength * dblHeight;

Re: Can someone please help me out?

Re: Can someone please help me out?

That's what I would do, yes. But if you want to be fully sure, then post the entire actual assignment text here. And you're welcome!

Re: Can someone please help me out?

public class Demo1

{

public static void main (String[] args)

{

int numberA, numberB, sum, difference;

numberA = 9;

numberB = 12;

sum = numberA + numberB;

difference = numberA - numberB;

System.out.println ("the sum of " + numberA + " plus " + numberB + " is " + sum);

System.out.println ("the difference of " + numberA " minus " + numberB + " is " + difference);

}

}

No idea whats wrong here but i get an error.

Calculate and display the result of taking the difference of numberA and numberB (ie. numberA – numberB). Your output should look like this…

the sum of 12 plus 9 is 21.

the difference 12 minus 9 is 3.

Re: Can someone please help me out?

Well, you're missing a plus sign ("+") in one of your println statements....

But for future, please use the code and /code tags and post the errors you get! I'm sure "sytax error on token ..." doesn't mean much to you now, but it will.