Results 1 to 11 of 11
Thread: Can someone please help me out?
 11032012, 09:22 PM #1Member
 Join Date
 Nov 2012
 Posts
 7
 Rep Power
 0
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?
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.
 11032012, 09:32 PM #3Member
 Join Date
 Nov 2012
 Posts
 7
 Rep Power
 0
Re: Can someone please help me out?
Ok hold on a second
 11032012, 09:40 PM #4Member
 Join Date
 Nov 2012
 Posts
 7
 Rep Power
 0
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.
 11032012, 09:46 PM #6Member
 Join Date
 Nov 2012
 Posts
 7
 Rep Power
 0
Re: Can someone please help me out?
I'm not sure if this is what the question is asking me to do.
 11032012, 09:50 PM #7Member
 Join Date
 Nov 2012
 Posts
 7
 Rep Power
 0
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;
 11032012, 09:51 PM #8Member
 Join Date
 Nov 2012
 Posts
 7
 Rep Power
 0
Re: Can someone please help me out?
Thank you for your help.

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!
 11032012, 10:28 PM #10Member
 Join Date
 Nov 2012
 Posts
 7
 Rep Power
 0
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.
 11032012, 11:26 PM #11Senior Member
 Join Date
 Oct 2012
 Posts
 108
 Rep Power
 0
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.Last edited by SJF; 11032012 at 11:26 PM. Reason: now not know
Bookmarks