We have to find the square feet of a room and determine how much paint it needs. The paint gallon coverage 350 square feet. For some reason, my code isn't working in the calculations. I know the problem is in the "if/else" statement, I just don't know what. I made an if-else statement to say that if the square feet is under 350, then to just make the gallons needed, 1. Just because we shouldn't leave it in decimals since it's supposed to be if you go to the store, you can't by the decimal size. Thanks
//import java scanner
import java.util.Scanner;
//declare variables
class Main {
final int COVERAGE =350; //paint covers 350sq. feet
int length, width, height;
double totalSqFt, paintNeeded;
//declare integers length, width, height
//declare doubles totalSqFt, paintNeeded
Scanner scan = new Scanner(System.in);
//this will run all the main methods
public void runProgram()
{
input();
calculations();
output();
}
//this will get the user input for the length, height, and width of the room
public void input()
{
System.out.println("Length of room:");
length = scan.nextInt();
scan.nextLine();
System.out.println("Height of room:");
height = scan.nextInt();
scan.nextLine();
System.out.println("Width of room:");
width = scan.nextInt();
scan.nextLine();
//Prompt for and read in the length of the room
//Prompt for and read in the height of the room
//Prompt for and read in the width of the room
}
//this calculates the user data for the amount of paint needed
public void calculations()
{
totalSqFt = height*width*2+height*length*2;
if (totalSqFt < 350){
paintNeeded = 1;
}else{
paintNeeded = (int)(totalSqFt / COVERAGE);
}
//Compute the total square feet of the walls to be painted
//Computer the amount of paint needed
}
//this prints out the calculations above
public void output()
{
System.out.println("Length: " + length + " Width: " + width + " Height: " + height);
System.out.println("Total Square Feet: " + totalSqFt + " \nGallons of Paint Needed: " + paintNeeded);
//Print the length, width, and height of the room and the gallons of paint needed.
}
public static void main(String[] args)
{
Main prog = new Main();
prog.runProgram();
}
}