Results 1 to 20 of 25
 04082009, 04:12 AM #1Member
 Join Date
 Apr 2009
 Posts
 34
 Rep Power
 0
[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
 04082009, 04:13 AM #2Member
 Join Date
 Apr 2009
 Posts
 34
 Rep Power
 0
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

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?
 04082009, 04:36 AM #4Member
 Join Date
 Apr 2009
 Posts
 34
 Rep Power
 0
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.

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.
 04082009, 04:54 AM #6Member
 Join Date
 Apr 2009
 Posts
 34
 Rep Power
 0
okay so when i get rid of the "...", which i did, you said add calculations..i dont get that part, can you specify

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 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 +...;
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 oneonone tutoring. You've got a lot of catching up to do and that offers your best way of doing so as quickly as possible.
 04082009, 05:36 AM #8Member
 Join Date
 Apr 2009
 Posts
 34
 Rep Power
 0
but this assignment is due tommorow, im going to try what you posted above, but i might need further help here.

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.
 04082009, 05:49 AM #10
Just post the errors you are getting
 04082009, 05:51 AM #11
As well as post your full coding here...
 04082009, 05:58 AM #12Member
 Join Date
 Apr 2009
 Posts
 34
 Rep Power
 0
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
 04082009, 11:15 AM #13Senior Member
 Join Date
 Dec 2008
 Location
 Hong Kong
 Posts
 473
 Rep Power
 12
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 useLast edited by mtyoung; 04082009 at 11:23 AM.
 04082009, 03:34 PM #14
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
the 2 errors are located right here netSquareFeet = (int)(grossSquareFeet)  (int)doors * DOOR_SIZE +...;
gallons = ...
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
 04082009, 09:17 PM #15Member
 Join Date
 Apr 2009
 Posts
 34
 Rep Power
 0
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?
 04082009, 10:31 PM #16
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 sizeJava Code:subtractions = (number of doors x door size) + (number of large windows x large window size) + (number of small windows x small window size)
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
 04092009, 12:08 AM #17Member
 Join Date
 Apr 2009
 Posts
 34
 Rep Power
 0
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;

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.
 04092009, 12:18 AM #19Member
 Join Date
 Apr 2009
 Posts
 34
 Rep Power
 0
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.
 04092009, 03:19 AM #20Member
 Join Date
 Apr 2009
 Posts
 34
 Rep Power
 0
Similar Threads

Errors in Program (Right Triangle)
By SupaStudy in forum New To JavaReplies: 3Last Post: 03262009, 10:42 AM 
What is the difference between Semantic Errors and Logical Errors?
By tlau3128 in forum New To JavaReplies: 3Last Post: 03082009, 01:51 AM 
Debuggin help  simple program nonstatic method errors
By RR_QQ in forum New To JavaReplies: 5Last Post: 02042009, 01:20 AM 
Help with Errors in Inventory Program
By ljk8950 in forum AWT / SwingReplies: 3Last Post: 08082008, 11:49 PM 
3 errors and then terminate program
By hezfast2 in forum New To JavaReplies: 2Last Post: 05202008, 01:57 AM
Bookmarks