Results 1 to 11 of 11
Like Tree1Likes
  • 1 Post By SJF

Thread: Can someone please help me out?

  1. #1
    coolkid456 is offline Member
    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Default 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.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Can someone please help me out?

    Quote Originally Posted by coolkid456 View Post
    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.

  3. #3
    coolkid456 is offline Member
    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Default Re: Can someone please help me out?

    Ok hold on a second

  4. #4
    coolkid456 is offline Member
    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Default 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?

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default 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.

  6. #6
    coolkid456 is offline Member
    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Default Re: Can someone please help me out?

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

  7. #7
    coolkid456 is offline Member
    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Default 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;

  8. #8
    coolkid456 is offline Member
    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Default Re: Can someone please help me out?

    Thank you for your help.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default 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!

  10. #10
    coolkid456 is offline Member
    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Default 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.

  11. #11
    SJF
    SJF is offline Senior Member
    Join Date
    Oct 2012
    Posts
    108
    Rep Power
    0

    Default 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; 11-03-2012 at 11:26 PM. Reason: now not know
    Fubarable likes this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •