The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 399 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
The object is to calculate the cost of a paint job A painting company has determined that for every 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. Modify your program so that it prints all values of money as numbers with exactly 2 decimal places.
Â
Expected Output:
Â
Enter the number of square feet: 224
Â
Enter the price of a gallon of paint: 20
Â
To paint 224.00 square feet, with paint that costs 20.00 per gallon,
Â
you will need 2 gallons of paint and 16.00 hours of labor.
Â
The cost of the paint is: 40.00
Â
The cost of the labor is: 560.00 The total cost of the job is: 600.00
public class PaintJobEstimator { // square feet per one gallon of paint. public static final double AREA_PER_GALLON = 112.0; // hours of labor needed to paint AREA_PER_GALLON square feet. public static final double HOURS_PER_UNIT_AREA = 8.0; // charge to customer for one hour of labor. public static final double LABOR_COST_PER_HOUR = 35.0; // main declares a Scanner that is passed to // the input methods. main also controls the // order of calculations. public static void main( String[] args ) { Scanner keyboard = new Scanner( System.in ); // How many square feet do we need to paint? double sqft = getInput( keyboard, "Enter the number of square feet: " ); double gallonCost = getInput( keyboard, "Enter the price of a gallon of paint: " ); int numGallons = calculateGallons( sqft ); double hoursLabor = calculateHours( sqft ); double paintCost = calculatePaintCost( numGallons, gallonCost ); double laborCost = calculateLaborCost( hoursLabor ); double totalCost = calculateTotalCost( paintCost, laborCost ); // Print the results. generateReport( sqft, gallonCost, numGallons, hoursLabor, paintCost, laborCost, totalCost); } public static double getInput( Scanner input, String prompt ) { System.out.print( prompt ); while ( !input.hasNextDouble() ) { input.nextLine(); // get rid of bad input. System.out.print( prompt ); } double inValue = input.nextDouble(); input.nextLine(); // clear the input line. return inValue; } // calculateGallons // calculateHours // calculatePaintCost // calculateLaborCost // calculateTotalCost // generateReport }
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll