# Help

Printable View

Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last
• 04-05-2009, 11:58 AM
moostico246
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
• 04-05-2009, 01:45 PM
Fubarable
This may help you get started:
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   }; }```
• 04-06-2009, 03:09 AM
moostico246
i dont get this at all, can u juss do it further
• 04-06-2009, 03:12 AM
Fubarable
Compile and run the code. It will be self-explanatory once you do so.
• 04-06-2009, 03:14 AM
moostico246
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
• 04-06-2009, 03:16 AM
Fubarable
7 errors in my code? What exactly do the error messages state?
• 04-06-2009, 03:17 AM
moostico246
yea, ma bad ur right theres 7...heres one error

PaintersHelper.java:22: <identifier> expected
int width, length, height, doors,
• 04-06-2009, 03:25 AM
Fubarable
Well much luck to you. You'll likely need it.
• 04-06-2009, 03:33 AM
OrangeDog
Compiles fine for me. Have you copied the text exactly into PaintersHelper.java (and nothing else)?

Btw, thanks Fubar, this is really helpful :)
• 04-06-2009, 03:33 AM
moostico246
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.
• 04-06-2009, 03:35 AM
Fubarable
Quote:

Originally Posted by moostico246
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?
• 04-06-2009, 03:35 AM
moostico246
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.
• 04-06-2009, 03:36 AM
moostico246
fuberable juss go somewher else, if u cant help, den dont worry about it.
• 04-06-2009, 03:41 AM
Fubarable
Nah, I'm having too much fun here to leave. It's kind of like shooting fish in a barrel.
• 04-06-2009, 03:43 AM
OrangeDog
Fish would be more fun, at least they have the inclination to move about a bit.
• 04-06-2009, 03:43 AM
Fubarable
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.
• 04-06-2009, 03:43 AM
moostico246
okay??wtf, dats not funny,can someone help here
• 04-06-2009, 03:51 AM
OrangeDog
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.
• 04-06-2009, 03:54 AM
moostico246
okay,, dat wasnt funny, and grow up lil boy..
• 04-06-2009, 04:02 AM
OrangeDog
It was quite funny. This has some good advice for someone in your position "big man":
New To Java - JAVA PROBLEM please help me
Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last