Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Multiplying variables in Java?

843789May 20 2009 — edited May 20 2009
Hi! I am a new computer student and I am working on my first project in Java for my class. I don't want someone to just give me the answer, I really need to learn this so please don't just give me the code. I'm stuck and I'm not sure where to go from here. This is what I need to do...

Project Description: Project 1 involves writing two versions of a program that a hardware store intends to let customers use to estimate the amount of paint they need to buy. The first program should calculate the amount of paint needed to paint the walls of a room given its dimensions. The second program should do the same, except it will allow the customer to enter additional information such as the number of doors and windows.

My teacher then helps us with giving us this part:
import java.util.Scanner; 
/** * Purpose: Determine how much paint is needed to paint the walls 
* of a room given its length, width, and height. 
* @author 

*/ public class Paint { public static void main(String[] args) { final int COVERAGE = 350; 
//paint covers 350 sq ft/gal 
//declare integers length, width, and height; 
//declare double totalSqFt; 
//declare double paintNeeded; 
//declare and initialize Scanner object 
//Prompt for and read in the length of the room 
//Prompt for and read in the width of the room 
//Prompt for and read in the height of the room 
//Compute the total square feet to be painted--think 
//about the dimensions of each wall 
//Compute the amount of paint needed 
//Print the length, width, and height of the room and the //number of gallons of paint needed. } }
Now....So far I have done this...FYI-I am using Eclipse.
package com.unf.project;
import java.util.Scanner;

/** 
 * * Purpose: Determine how much paint is needed to paint the walls 
 * * of a room given its length, width, and height. 
 * * @author */ 
public class Paint

{ 
	public static void main(String[] args) 
	{ 
		final int COVERAGE = 350; //paint covers 350 sq ft/gal 
	
		//declare integers length, width, and height; 
		double lengthOfRoom;
		double heightOfRoom;
		double widthOfRoom;
		//declare double totalSqFt; 
		double totalSqFt;
		//declare double paintNeeded; 
		double paintNeeded;
		//declare and initialize Scanner object 
		Scanner scan = new Scanner (System.in);
		//Prompt for and read in the length of the room 
		System.out.print("Room Length? (ex. 12.5)");
		lengthOfRoom = scan.nextDouble();
		//Prompt for and read in the height of the room 
		System.out.print("Room Height? ");
		heightOfRoom = scan.nextDouble();
		//Prompt for and read in the width of the room 
		System.out.print("Room Width? ");
		widthOfRoom = scan.nextDouble();
					
		//Compute the total square feet to be painted--think 
		//about the dimensions of each wall 
		2*(widthOfRoom*heightOfRoom)+ 2*(lengthOfRoom*heightOfRoom);
		
		
		//Compute the amount of paint needed 
		
		//Print the length, width, and height of the room and the 
		//number of gallons of paint needed. } }
	}
}
I am getting an error on this line
2*(widthOfRoom*heightOfRoom)+ 2*(lengthOfRoom*heightOfRoom);

It says that I need a variable on the left side....So does that mean hat I need to declare 2 a variable?? UGGG!! I'm really lost....Any help would be greatly appreciated! Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 17 2009
Added on May 20 2009
6 comments
480 views