Debugging (java) | Computer Science homework help

Overview

Many Java programs that you create will receive and process user input. In order to ensure that user input is accurate, you will need to use input validation and exception handling. For example, if you ask for a zip code, you want to ensure the user inputs a five-digit number. In this activity, you are given “buggy” code for a paint program that calculates the number of cans of paint required to paint a wall, given the wall’s height and width. You will need to debug the code and improve it by adding code to validate user input and handle exceptions.

Prompt

For this assignment, you will complete the paint program by debugging the original code and adding code that validates user input and handles exceptions. Use the Uploading Files to Eclipse and the Downloading Files From Eclipse tutorials to help you with this project.

  • Debugging
    • Open the Virtual Lab by clicking on the link in the Virtual Lab Access module. Then open your IDE. Upload the Paint1.zip folder and review the code for the Paint1.java file.
    • Find and fix the three errors in the given code.
    • Use the input values below to test your program. If you found and fixed all errors, your output should exactly match what is below.
      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.

Input value table with the numerals 30 and 25

Output value table with the wall area as 750.0 square feet and the paint needed as 2.142857142857143 gallons

  • Input Validation and Exception Handling
    • Review the code, looking for the two code blocks where user input is required.
    • Implement a do-while loop in both blocks of code to ensure that input is valid and any exceptions are handled.
      TIP: Consider using a try-catch block for exception handling, but it is not required.
    • Use the two sample invalid inputs below to test your program. Your program should respond to each by prompting the user to enter valid input. This should continue to loop until valid input is received.

A table with two columns titled Input 1 and Input 2. The items under Input 1 are the spelled-out number thirty and the numeral 25. The items under Input 2 are the numerals 30 and 0.

THINK: Why is 0 invalid input for this problem? What is the user being asked to input?

Guidelines for Submission

Attach your completed Paint1.java file to the assignment submission page.

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more