2. First, you will debug the Paint1 class so that no errors remain and all calculations...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. First, you will debug the Paint1 class so that no errors remain and all calculations work correctly by completing the following: o Find and fix the three errors in the given code. o Use the following sample input values to test your program. If you have found and fixed all the errors, your output should exactly match the sample. Input: 30 25 Output: Wall area: 750.0 square feet Paint needed: 2.142857142857143 gallons Tip: When you run your program in Eclipse, it will prompt you to enter input in the Console window. If you cannot find this window, go to Window, then Show View, then Console. 3. Next, you will add loops to validate all user input and handle exceptions so that code passes all test cases by completing the following: o Review the code, looking for the two code blocks where user input is required. o Implement a do-while loop in both blocks of code to ensure that input is valid and any exceptions are handled. o Use the two following sample sets of input to test your program. Since these inputs are invalid, your program should respond to each by prompting the user to enter valid input. This should continue to loop until valid input is received. import java.util.Scanner; public class Paintl { } public static void main(String[] args) { Scanner scnr = new Scanner (System.in); double wallHeight = 0.0; double wallWidth = 0.0; double wallArea = 0.0; double gallons PaintNeeded = 0.0; } final double square Feet PerGallons = 350.0; // Implement a do-while loop to ensure input is valid // Prompt user to input wall's height System.out.println("Enter wall height (feet): "); wallHeight = scnr.nextDouble(); // Implement a do-while loop to ensure input is valid // Prompt user to input wall's width System.out.println("Enter wall width (feet): "); wallHeight = scnr.nextDouble(); // Calculate and output wall area wallArea = wallHeight * wallWidth; System.out.println("Wall area: square feet"); // Calculate and output the amount of paint (in gallons) needed to paint the wall gallons PaintNeeded = wallArea/square Feet PerGallons; System.out.println("Paint needed: " + gallonspaintneeded + " gallons"); 2. First, you will debug the Paint1 class so that no errors remain and all calculations work correctly by completing the following: o Find and fix the three errors in the given code. o Use the following sample input values to test your program. If you have found and fixed all the errors, your output should exactly match the sample. Input: 30 25 Output: Wall area: 750.0 square feet Paint needed: 2.142857142857143 gallons Tip: When you run your program in Eclipse, it will prompt you to enter input in the Console window. If you cannot find this window, go to Window, then Show View, then Console. 3. Next, you will add loops to validate all user input and handle exceptions so that code passes all test cases by completing the following: o Review the code, looking for the two code blocks where user input is required. o Implement a do-while loop in both blocks of code to ensure that input is valid and any exceptions are handled. o Use the two following sample sets of input to test your program. Since these inputs are invalid, your program should respond to each by prompting the user to enter valid input. This should continue to loop until valid input is received. import java.util.Scanner; public class Paintl { } public static void main(String[] args) { Scanner scnr = new Scanner (System.in); double wallHeight = 0.0; double wallWidth = 0.0; double wallArea = 0.0; double gallons PaintNeeded = 0.0; } final double square Feet PerGallons = 350.0; // Implement a do-while loop to ensure input is valid // Prompt user to input wall's height System.out.println("Enter wall height (feet): "); wallHeight = scnr.nextDouble(); // Implement a do-while loop to ensure input is valid // Prompt user to input wall's width System.out.println("Enter wall width (feet): "); wallHeight = scnr.nextDouble(); // Calculate and output wall area wallArea = wallHeight * wallWidth; System.out.println("Wall area: square feet"); // Calculate and output the amount of paint (in gallons) needed to paint the wall gallons PaintNeeded = wallArea/square Feet PerGallons; System.out.println("Paint needed: " + gallonspaintneeded + " gallons");
Expert Answer:
Answer rating: 100% (QA)
The updated source code that meets all the requirements im... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
5. If a spacecraft was approaching an object of large mass what would happen to the radio signals transmitted from the spacecraft as it gets closer to the mass?
-
Two-dimensional array operations: Movie Ratings program ** You have recently collected reviews from four movie reviewers where the reviewers are numbered 1-4. Each reviewer has rated six movies where...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
A Howe scissors roof truss is loaded as shown. Determine the force in members DF, DG, and EG. 2AN KN 2kN F! 1AN L5 m
-
One liter (1000cm3) of oil is spilled onto a smooth lake. If the oil spreads out uniformly until it makes an oil slick just one molecule thick, with adjacent molecules just touching, estimate the...
-
a) Find the perimeter of a square in which each side measures 13 inches. b) Determine the length of the fence you'd need to enclose a lawn that's a rectangle with sides of 25 ft and 30 ft. c) Find...
-
Suppose an investor has exponential utility function $U(x)=$ $-e^{-a x}$ and an initial wealth level of $W$. The investor is faced with an opportunity to invest an amount $w \leq W$ and obtain a...
-
Eric, your friend, received his Form W-2 from his employer (below) and has asked for your help. Erics 2018 salary was $145,000 and he does not understand why the amounts in Boxes 1, 3 and 5 are not...
-
How do contingency factors, such as organizational size, industry dynamics, and institutional pressures, influence the optimal design of organizational structures and necessitate periodic...
-
During 2019, Jason and Vicki Hurting, who are married with two children and filing jointly, had the following tax information. Jason owns a cash-basis landscaping business, and Vicki works as a sales...
-
1. (50 points) Design the simplest circuit that has four inputs, a, b, c, and d, which produces an output value of 1 whenever three or more of the input variables have the value 1; otherwise, the...
-
After successful stretches at Target and Apple, it seemed as though Ron Johnson was a master marketer. But things went sour quickly after JC Penney hired him as its CEO. Johnsons attempt to reinvent...
-
How did the Fed hit its target for the federal funds rate in the pre-2008 scarce-reserves regime?
-
What is the zero lower bound in monetary policy? What tools can the Fed use if it wants to implement an expansionary monetary policy at the zero lower bound?
-
Trademark disputes often pit a large company against a startup. This is a David-versus-Goliath type of scenario, with a small entity on one side against a giant on the other. Commonly, this type of...
-
A feature on the Wall Street Journals website titled The Fed: Questions & Answers contains the following statement: The Fed cant control inflation or influence output and employment directly;...
-
Figure 12.1. Sample team charter Team Charter Our team charter is an agreement among our team members about our team mission and goals, and the ground rules for behavior, operation, and management of...
-
What did Lennox gain by integrating their WMS, TMS, and labor management systems?
-
Russell (age 50) and Linda (age 45) Long have brought you the following information regarding their income and expenses for the current year. Russell owns and operates a landscaping business called...
-
Sophie is a single taxpayer. For the first payroll period in October 2012, she is paid wages of $3,250 monthly. Sophie claims three allowances on her Form W-4. a. Use the percentage method to...
-
Charlie's Green Lawn Care is a cash basis taxpayer. Charlie Adame, the sole proprietor, is considering delaying some of his December 2012 customer billings for lawn care into the next year. In...
-
Ive heard that economists build a lot of theories. Thats why I think that economics might be too abstract a course of study. Theories come with a lot of mathematics, diagrams, and complex terms. I...
-
What does it mean if you are included in another persons utility function in a positive way?
-
Can evidence prove that a theory is correct?
Study smarter with the SolutionInn App