school/painting-a-wall/painting_a_wall.java

30 lines
692 B
Java
Raw Normal View History

2021-01-20 06:57:22 -05:00
import java.util.Scanner;
public class painting_a_wall {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
double height, width;
final double square_feet_per_gallon = 350;
System.out.println("Enter wall height (feet):");
height = scnr.nextDouble();
System.out.println("Enter wall width (feet):");
width = scnr.nextDouble();
System.out.println("Wall area: " + height*width +
" square feet");
System.out.println("Paint needed: " +
(height*width)/square_feet_per_gallon +
" gallons");
System.out.println("Cans needed: " +
(int)Math.ceil((height*width)/square_feet_per_gallon)+
" can(s)");
scnr.close();
}
}