Page 1 of 2 12 LastLast
Results 1 to 20 of 25
  1. #1
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

    Default [SOLVED] hello, java program with 2 errors, help

    Hi I am trying to compile and run this file but there is two errors: here is the original assignment but I did the rest.

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

    Programmer:
    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
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

    Default

    Heres what I have done so far...
    /* This program calculates the number of gallons of paint
    needed to paint a room.

    Programmer: your name
    Date: April 5, 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;
    int width, length, height, doors;
    int grossSquareFeet;
    // give welcome and instructions to user

    System.out.println("Welcome to the Painters Helper!" );

    Scanner input = new Scanner(System.in);

    System.out.println("Please enter the room's width:");
    width = input.nextInt();

    grossSquareFeet = height * 2 * (length + width);
    netSquareFeet = (int)(grossSquareFeet) - (int)doors * DOOR_SIZE +...;
    gallons = ...

    System.out.println("\nYou will need about " + gallons + " gallons of paint.");

    } // end of method main

    } // end of class PaintersHelper

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

    Default

    Hello moostico.

    First of all:
    1) what exactly are the current error messages?
    2) does your code have the ellipses (the "..." statements) in it? And if so, why?

  4. #4
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

    Default

    well,hello, and the 2 errors are located right here netSquareFeet = (int)(grossSquareFeet) - (int)doors * DOOR_SIZE +...;
    gallons = ...

    its saying that illegal start of expression..I atleast tried it, so you can't really say im lazy now...gimmie some credit here.

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

    Default

    get rid of the "..." and add calculations for the small and large windows, etc. it looks like you should have enough info to be able to figure out how to do these.

  6. #6
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

    Default

    okay so when i get rid of the "...", which i did, you said add calculations..i dont get that part, can you specify

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

    Default

    You appear to know how to get information from the user, or how to prompt the user:
    Java Code:
    System.out.println("Please enter the room's width:");
    width = input.nextInt();
    You'll need to do something similar with all the variables including the number of small windows and large windows.

    You appear to know how to use these variables obtained to calculate part of the area that needs to be painted:
    Java Code:
    grossSquareFeet = height * 2 * (length + width);
    netSquareFeet = (int)(grossSquareFeet) - (int)doors * DOOR_SIZE +...;
    (although you need to enclose (int)(doors * DOOR_SIZE) in parenthesis as noted above).

    Well use the information provided by the user to extend your calculations -- to subtract the total area of the small and large windows, etc. Just do what you've done above but using the other values obtained from the user.

    My other suggestion is to talk to your teacher about getting one-on-one tutoring. You've got a lot of catching up to do and that offers your best way of doing so as quickly as possible.

  8. #8
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

    Default

    but this assignment is due tommorow, im going to try what you posted above, but i might need further help here.

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

    Default

    you really need to think on this, and think hard. Then try to create code that conforms to what you think should work, then when it doesn't use the error messages to help you fix it. Eventually through this process, you will get success, and it will be yours, and yours alone. Just jump right in and play with your code. You've got nothing to lose.

  10. #10
    jlover's Avatar
    jlover is offline Member
    Join Date
    Apr 2009
    Posts
    5
    Rep Power
    0

    Default

    Just post the errors you are getting

  11. #11
    jlover's Avatar
    jlover is offline Member
    Join Date
    Apr 2009
    Posts
    5
    Rep Power
    0

    Default

    As well as post your full coding here...

  12. #12
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

    Default

    ok i tried messing around with it for a lil bit, but still getting juss two errors. well and the 2 errors are located right here netSquareFeet = (int)(grossSquareFeet) - (int)doors * DOOR_SIZE +...;
    gallons = ...

    its saying that illegal start of expression



    the full code is::
    /* This program calculates the number of gallons of paint
    needed to paint a room.

    Programmer: your name
    Date: April 5, 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;
    int width, length, height, doors;
    int grossSquareFeet;
    // give welcome and instructions to user

    System.out.println("Welcome to the Painters Helper!" );

    Scanner input = new Scanner(System.in);

    System.out.println("Please enter the room's width:");
    width = input.nextInt();

    grossSquareFeet = height * 2 * (length + width);
    netSquareFeet = (int)(grossSquareFeet) - (int)doors * DOOR_SIZE +...;
    gallons = ...

    System.out.println("\nYou will need about " + gallons + " gallons of paint.");

    } // end of method main

    } // end of class PaintersHelper

  13. #13
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    1)
    what is the value of doors?
    is doors initialized?
    and so for height, length?


    2)
    netSquareFeet ... what is it? int, double, float etc?
    declare (and may initialize) it before use
    Last edited by mtyoung; 04-08-2009 at 11:23 AM.

  14. #14
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default

    Just follow the template that you have been given. You've already asked for the room's width, just keep asking for the other parameters' that you need (length, heigth, number of doors, smal and large windows, etc). Then you can start with the caculations (you need these parameters to do the calculations).
    About the errors... most Java statements end with a semicolon ( ; ). There are no statements in Java that are "...".
    okay so when i get rid of the "...", which i did
    ... but you didn't, because then you posted again the following:
    the 2 errors are located right here netSquareFeet = (int)(grossSquareFeet) - (int)doors * DOOR_SIZE +...;
    gallons = ...
    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  15. #15
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

    Default

    i took the "..." out and theres still two errors, now i think a calculation is needed, but how do i start with the calculation for this code?

  16. #16
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default

    Do you have all info that is requested? Room heigth, length, # windows, # doors, etc? the first calculation is the subtractions:
    subtractions is the sum of:
    // number of doors * door size
    // number of lgWindows * lgWindow size
    // number of smWindows * smWindow size
    Java Code:
    subtractions = (number of doors x door size) + 
                   (number of large windows x large window size) +
                   (number of small windows x small window size)
    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  17. #17
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

    Default

    thanx man,,,now is this wat u wanted for the Room heigth, length, # windows, # doors, etc?

    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;

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

    Default

    No. what you need to do is to read critically what has already been done in this code above for doors and try to replicate it for small and large windows. Please talk to your instructor without delay. You need to get up to speed and this forum can only help so much.

  19. #19
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

    Default

    ill tlk to my instructor the next time i have class, but this assignment is late now, can u juss walk me through some of the rest of the steps.

  20. #20
    einstein1234 is offline Member
    Join Date
    Apr 2009
    Posts
    34
    Rep Power
    0

    Default

    ive read alot, does anyone here have the time to walk me through fixing these errors, or give me specific readings, or help me

Page 1 of 2 12 LastLast

Similar Threads

  1. Errors in Program (Right Triangle)
    By SupaStudy in forum New To Java
    Replies: 3
    Last Post: 03-26-2009, 10:42 AM
  2. Replies: 3
    Last Post: 03-08-2009, 01:51 AM
  3. Replies: 5
    Last Post: 02-04-2009, 01:20 AM
  4. Help with Errors in Inventory Program
    By ljk8950 in forum AWT / Swing
    Replies: 3
    Last Post: 08-08-2008, 11:49 PM
  5. 3 errors and then terminate program
    By hezfast2 in forum New To Java
    Replies: 2
    Last Post: 05-20-2008, 01:57 AM

Posting Permissions

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