subject

Your original program calculated the amount of paint needed, but depending on the width and height, that value could be a long decimal. Your program will better suit the needs of the user if it can calculate the number of cans needed as an integer value. For example, given that 1 gallon = 1 can of paint, we might expect the Paint program from Module Six to output:
Paint needed: 2.142857142857143 gallons
Cans needed: 3.0 can(s)

You might at first think that you could just cast the gallonsPaintNeeded variable from a double to an integer type. However, that would merely cut off the decimal portion of the value, resulting in an underestimate of the number of cans needed. You might also consider rounding the number, but that would not work for the sample output provided above since normal rounding rules would suggest 2.0 cans, an underestimate. So, the computational problem you are faced with is to calculate the number of cans and round up to the nearest whole number. In order to determine if that method for rounding up exists as part of one of Java’s core classes, we need to consult the documentation. There might be a single method that we can use or we might have to use more than one method.

package Paint1;

import java. util. Scanner;
import java. lang. Math;

public class PaintEstimator {

public static void main(String[]args) {
Scanner sc = new Scanner(System. in);
double wallHeight = 0;
double wallWidth = 0.0;
double wallArea = 0;
double gallonsPaintNeeded = 0;
int cansNeeded = 0;

final double squareFeetPerGallon = 350.0;
final double gallonsPerCan = 1.0;

do{
System. out. println("Enter wall height (feet): ");
wallHeight = sc. nextDouble();
}
while(wallHeight <= 0 );

do {
System. out. println("Enter wall width (feet): ");
wallWidth = sc. nextDouble();
}
while((wallWidth <= 0));
wallArea = wallHeight * wallWidth;
System. out. println("Wall area: " + wallArea + "square feet");

gallonsPaintNeeded = wallArea/squareFeetPerGallon;
System. out. println("Paint needed: " + gallonsPaintNeeded + " gallon(s)");

cansNeeded = (int)(Math. ceil(gallonsPaintNeeded)/Math. ceil(gallonsPerCan));

System. out. println("Cans needed: " + (cansNeeded) + " can(s)");
return;
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:30
Word vocabulary words: print, proofread, status line, graphics, font effects, left margin, justification, line spacing, copy/paste, data. review words: font point, bold, save, center, error. fill in the correct word for the definition and then transfer the letters to the appropriate spot by number. some numbers will be found multiple times. you will end up with a quotation about…… what else? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 k 16 17 18 19 20 21 22 23 24 25 8 27 28 29 w 31 32 k 34 35 36 w h 39 40 41 42 8 44 45 46 47 48 49 50 51 52 53 54 55 .1. a software function that records keystrokes on a disk or drive so information can be 5 4 52 9 later retrieved. p n 2. to produce a paper copy of information. 10 7 12u n 3. a display that shows the location of the cursor, pages, etc. 45 46 18 27 36 20 42p4. pictures or images, located in clip art or other files. 6 24 44 28 34 49 555. any mis-stroke of a key. 47 41 48 2 10 n6. allows major changes to the font such as shadow, emboss, etc. 21 25 46 35 23 21 29 14 22 17 n7. a feature that centers lines of text horizontally. 49 53 46 9 51 p8. size of the font 31 16 22 b l 9. a feature that prints designated text darker than the rest to add emphasis. 32 3 . p10. to compare copy on a display screen or printout to the original 24 39 25 23 54 9 50 3 and correct errors. j un 11. a feature that allows text to be aligned at the left 11 12 7 21 16 49 40 46 34 2 and right margins. leftn 12. amount of blank space on the left side of the paper. 8 18 41 6 34 linen 13. number of blank lines between lines of text. 17 4 49 13 1914. any information inputted into the computer. 3 4 46 44 p /p15. feature that duplicates text from one location and places it in another.
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
Need ! will choose brainliest! discuss the role of abstraction in the history of computer software.
Answers: 1
question
Computers and Technology, 23.06.2019 21:20
For positive constants a and b, the force between two atoms in a molecule is given f(r) = −a r2 + b r3 , where r > 0 is the distance between the atoms. note: a and b are upper case letters. (a) find f '(r) = (b) find the critical point for f(r). r = (c) find f ''(r) = (d) find the value of r so that f ''(r) = 0.
Answers: 1
You know the right answer?
Your original program calculated the amount of paint needed, but depending on the width and height,...
Questions
question
Mathematics, 14.09.2020 15:01
question
Mathematics, 14.09.2020 15:01
question
English, 14.09.2020 15:01
question
Mathematics, 14.09.2020 15:01
question
Spanish, 14.09.2020 15:01
question
Geography, 14.09.2020 15:01
question
Health, 14.09.2020 15:01
question
Mathematics, 14.09.2020 15:01
question
Mathematics, 14.09.2020 15:01
question
English, 14.09.2020 15:01
question
English, 14.09.2020 15:01
question
Mathematics, 14.09.2020 15:01
question
Mathematics, 14.09.2020 15:01
question
Geography, 14.09.2020 15:01
question
Mathematics, 14.09.2020 15:01
question
Mathematics, 14.09.2020 15:01
question
Biology, 14.09.2020 15:01
question
Mathematics, 14.09.2020 15:01
question
Mathematics, 14.09.2020 15:01
question
History, 14.09.2020 15:01
Questions on the website: 13722367