Skip to content

Instantly share code, notes, and snippets.

@agaviria
Last active Sep 10, 2016
Embed
What would you like to do?
Helping a friend with a java assignment
import java.util.Scanner;
public class PaintCalc {
public static void main(String[] args) {
System.out.println("This program calculates the gallons needed to paint a room.");
final int GAL_PAINT_COVERAGE = 350;
double l, w, h;
double sqft;
double gallonsNeeded;
// Get length from user
System.out.println("Enter length of room (Ft): ");
Scanner scan = new Scanner(System.in);
l = scan.nextDouble();
// Get width from user
System.out.println("Enter width of room (Ft): ");
w = scan.nextDouble();
// Get height from user
System.out.println("Enter height of room (Ft): ");
h = scan.nextDouble();
sqft = 2 * (l * w * h); //declaring object
gallonsNeeded = sqft / GAL_PAINT_COVERAGE;
System.out.println("Gallons needed to paint this square footage: " + gallonsNeeded);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment