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
-
A trapezoidal aqueduct has b = 5 m and θ = 40° and carries a normal flow of 60 m3/s when y = 3.2 m. For clay tile surfaces, estimate the required elevation drop in m/km. 40 y 3.2 m 40 5 m
-
(a) Show that the set of all functions of the form f(x) = (ax2 + bx + c) ex for a, b, c, R forms a vector space. What is its dimension? (b) Show that the derivative D[f(x)] = f(x) defines an...
-
An engineering student wanted to know which factors influence the time (in seconds) for his car to go from 0 to 30 to 0 miles per hour. Factor \(A\) was the launch, which was either no wheel spin or...
-
For the third quarter of the year, Johnson Company, 415 Circle Avenue, Chicago, Illinois 60652, received Form 941 from the Internal Revenue Service. The identification number of Johnson Company is...
-
What is the importance of employee-driven content? To appeal to adult learners, what do delivery methods need to include, and why?
-
b. Prepare all consolidating entries needed to prepare consolidated statements for 20X5. (If no entry is required for a transaction/event, select "No journal entry required" in the first account...
-
3-4. A simple well-known game, tic-tac-toe, is played on a three-by-three grid of squares by two players. The players alternate tums. Each player chooses a square and places a mark in a square. (One...
-
A 1 0 - year bond with a par value of $ 1 0 , 0 0 0 will mature in 2 0 years for $ 1 0 , 5 0 0 . The coupon rate is 8 % convertible semiannually. Calculate the price that Andrew would pay if he...
-
In the last quarter, Terra Inc. sold 1914 units of hard drives. Each of the hard drives were priced at $62, on average. The CMO is considering a price change to $ 55 each and has asked the marketing...
-
The motion of a car is described by the position vs . ?time graph shown below. At which of the three labeled times is the magnitude of the velocity ( i . e . , ?the speed ) ?of the car the greatest?...
-
Claremont * VERY Due Date: October 12, 2011 Total: 100 points (each question is worth 10 points) 1. a. Prove that the inverse transpose operation [(A) (A)) respects matrix multiplication:...
-
You have the following cash flows for a possible project: Years Cash flows 0 -3000 1 700 2 750 3 4 5 1,000 800 700 Calculate the DCF The discount rates should be in a percentage format to two decimal...
-
You are going to value Lauryn's Doll Co. using the FCF model. After consulting various sources, you find that Lauryn's has a reported equity beta of 1.7, a debt-to-equity ratio of 0.4, and a tax rate...
-
What are the key elements of a system investigation report?
-
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...
-
Model your car by using analogy approach and stable approach. Which one do you like more and why?
-
Model your dream house by using analogy approach and stable approach. Which one do you like more and why?
-
Try to find 23 scenarios where this pattern can be applicable.
Study smarter with the SolutionInn App