Created
October 1, 2013 17:26
-
-
Save imryan/6782061 to your computer and use it in GitHub Desktop.
CS 2 paint bucket calculator.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Paint { | |
static Scanner sc = new Scanner(System.in); | |
public static void main(String[] args) { | |
// Declare variables to be used | |
final int ONE_GAL_PAINT = 350; | |
double width = 0.0, length = 0.0, height = 0.0, total = 0.0; | |
double windowTotal = 0.0, doorTotal = 0.0; | |
// Get the user input | |
width = sc.nextDouble(); | |
length = sc.nextDouble(); | |
height = sc.nextDouble(); | |
windowTotal = sc.nextDouble(); | |
doorTotal = sc.nextDouble(); | |
// Add up the window & door totals | |
windowTotal *= 15.0; | |
doorTotal *= 20.0; | |
// Calculate the totals | |
total = (width * height * 2) + (length * height * 2); | |
total -= (windowTotal + doorTotal); | |
System.out.println("\nTotal: " + total); | |
// Find out the number of gallons needed | |
total /= ONE_GAL_PAINT; | |
total = Math.ceil(total); | |
// Output the final value | |
System.out.println("Total paint gallons: " + total); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment