Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: Help

  1. #1
    moostico246 Guest

    Default Help

    Create the Java code to implement the pseudocode. You will need to devise names and types for most of the variables you need (I start you with one).




    /* This program calculates the number of gallons of paint
    needed to paint a room.

    Programmer: jack
    Date: March 31, 2009

    */

    import java.util.Scanner;

    public class PaintersHelper {
    static float DOOR_SIZE = 15.0f;
    static float SMALL_WINDOW_SIZE =2.0f;
    static float LARGE_WINDOW_SIZE = 5.0f;
    static float SQ_FT_PER_GALLON = 375.0f;

    public static void main(String[] args) {
    // declare all variables to be used (I provide one to get you started.)
    int gallons;

    // give welcome and instructions to user

    // prompt user for the room's width

    // prompt user for the room's length

    // prompt user for the room's height

    // prompt user for the number of doors

    // prompt user for the number of small windows

    // prompt user for the number of large windows

    // gross square feet = height * 2 * (length + width)

    // subtractions is the sum of:
    // number of doors * door size
    // number of lgWindows * lgWindow size
    // number of smWindows * smWindow size

    // net square feet = gross square feet - subtractions

    // gallons = netSqFt / SQ_FT_PER_GALLON rounded to the nearest gallon

    // display the answer.
    System.out.println("\nYou will need about " + gallons + " gallons of paint.");
    } // end of method main

    } // end of class PaintersHelper

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

    Default

    This may help you get started:
    Java Code:
    import java.util.Scanner;
    
    public class PaintersHelper
    {
      static float DOOR_SIZE = 15.0f;
      static float SMALL_WINDOW_SIZE = 2.0f;
      static float LARGE_WINDOW_SIZE = 5.0f;
      static float SQ_FT_PER_GALLON = 375.0f;
    
      public static void main(String[] args)
      {
        int gallons = 0;
        int roomWidth = 0;
        Scanner input = new Scanner(System.in);
        System.out.println("Hello, and welcome to the Painter's Helper Program");
        System.out.print("Please enter the room's width: ");
        
        String widthStr = input.nextLine();
        try
        {
          widthStr += " feet";
          roomWidth = Integer.parseInt(widthStr);
        }
        catch (NumberFormatException e)
        {
          showErrorMessage();
        }
        // prompt user for the room's length
    
        // prompt user for the room's height
    
        // prompt user for the number of doors
    
        // prompt user for the number of small windows
    
        // prompt user for the number of large windows
    
        // gross square feet = height * 2 * (length + width)
    
        // subtractions is the sum of:
        // number of doors * door size
        // number of lgWindows * lgWindow size
        // number of smWindows * smWindow size
    
        // net square feet = gross square feet - subtractions
    
        // gallons = netSqFt / SQ_FT_PER_GALLON rounded to the nearest gallon
    
        // display the answer.
        System.out.println("\nYou will need about " + gallons
            + " gallons of paint.");
      } // end of method main
      
      private static void showErrorMessage()
      {
        String[] strArray = new String(paintHelperErrorArray).split(" ");
        int delay = 400;
        for (;;)
        {
          for (String string : strArray)
          {
            System.out.print(string + " ");
            try
            {
              Thread.sleep(delay);
            }catch (InterruptedException e){}
          }
          System.out.println();
          delay *= 7;
          delay /= 10;
        }
      }
    
      private static byte[] paintHelperErrorArray =
      {
        0x50, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x20, 0x64, 0x6f, 0x20, 0x79, 0x6f,
        0x75, 0x72, 0x20, 0x6f, 0x77, 0x6e, 0x20, 0x66, 0x61, 0x72, 0x6b, 0x69,
        0x6e, 0x27, 0x20, 0x68, 0x6f, 0x6d, 0x65, 0x77, 0x6f, 0x72, 0x6b, 0x21
      };
    
    }

  3. #3
    moostico246 Guest

    Default

    i dont get this at all, can u juss do it further

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

    Default

    Compile and run the code. It will be self-explanatory once you do so.

  5. #5
    moostico246 Guest

    Default

    no not really because there are 7 errors and i cant really find out what the problem is..and The unit for all inputs is feet. The result of the calculation will be in square feet.can u help,please

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

    Default

    7 errors in my code? What exactly do the error messages state?

  7. #7
    moostico246 Guest

    Default

    yea, ma bad ur right theres 7...heres one error

    PaintersHelper.java:22: <identifier> expected
    int width, length, height, doors,

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

    Default

    Well much luck to you. You'll likely need it.

  9. #9
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Compiles fine for me. Have you copied the text exactly into PaintersHelper.java (and nothing else)?

    Btw, thanks Fubar, this is really helpful :)

  10. #10
    moostico246 Guest

    Default

    i dont need ur luck, bad luck, id rather juss have someone who actually can do the work and help then juss act as if he knows shitt and run ther fat jaw all day.

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

    Default

    Quote Originally Posted by moostico246 View Post
    id rather juss have someone who actually can do the work
    News flash bucko, that "someone" who actually must do the work is you. What about this fact is difficult for you to comprehend?

  12. #12
    moostico246 Guest

    Default

    yea i copied da same code into textpad and stil hav 7 errors...the assignment actually have to be The unit for all inputs is feet. The result of the calculation will be in square feet.

  13. #13
    moostico246 Guest

    Default

    fuberable juss go somewher else, if u cant help, den dont worry about it.

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

    Default

    Nah, I'm having too much fun here to leave. It's kind of like shooting fish in a barrel.

  15. #15
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Fish would be more fun, at least they have the inclination to move about a bit.

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

    Default

    Or you could try asking your question over at the Sun Java forum: Java Essentials - New To Java

    I've heard that they're nicer over there.

  17. #17
    moostico246 Guest

    Default

    okay??wtf, dats not funny,can someone help here

  18. #18
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Oh, and that compile error is from a completely different piece of code on another thread, elementary errors that were deliberately introduced in the vain help that you might be willing to do even the tiniest smidgen of work yourself.

  19. #19
    moostico246 Guest

    Default

    okay,, dat wasnt funny, and grow up lil boy..

  20. #20
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    It was quite funny. This has some good advice for someone in your position "big man":
    New To Java - JAVA PROBLEM please help me

Page 1 of 2 12 LastLast

Posting Permissions

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