Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please follow all directions, add in line comments to help better understand A note for good coding practices: Starting with this assignment, you need to

please follow all directions, add in line comments to help better understand

image text in transcribedimage text in transcribed
A note for good coding practices: Starting with this assignment, you need to incorporate the following concepts/practices in your code as required by the problem statement. Do not expect them to be spelled out in individual problem statement or subsequent assignments. This and subsequent assignments will be assessed for utilization of these concepts in the code. - Apply the concept of encapsulation. - Always declare variables as private. - Provide setters and getters methods to allow access to class variables as per the problem statement requirements and the role/purpose of each variable in the solution. - Always declare support methods as private. - Allow the user to enter input values to facilitate code test-ability. DO not hard code inputs unless stated in the problem statement. - Allow the user to re-run the code in the same session using a sentinel loop. - Always sanitize/validate input values as soon as being entered to make sure they are "good" values (using assertions or if statements).Develop a complete Java program for each of the following problems. Please name the programs as indicated and add proper program headers and output labels as shown below. Please use only concepts and programming constructs/syntax we discuss to date. Make sure you include a header for each program (see previous assignments). Program #1 (13 points): Design and implement a Java class, named MismatchException, to determine the average of four integer grades between 0 and 100. Please Do Not read user inputs as strings, user may enter one integer value per line. The program must catch-and-try exception handling block to detect invalid inputs (InputMismatchException). If an invalid input value is detected, the program prompts the user to re-enter four valid grades. The following sample test data shows input prompts and output labels and format. The sample test data below assumes that the user enters all numbers on one line as shown. User may enter one value per line. First test: Enter four grades between 0 and 100: 10 20 30 40 Entered grades are: 10, 20, 30, 40 Student Average: 25.00 Second test: Enter four grades between 0 and 100: 20 75 90 97.50 Incorrect input, re-enter valid grades: 20 75 90 g Incorrect input, re-enter valid grades: 20 75 90 ; Incorrect input, re-enter valid grades: 20 75 this 97 Incorrect input, re-enter valid grades: 20 75 90 97 Entered grades are: 20, 75, 90, 97 Student Average: 70 . 50 Third test: Enter four grades between 0 and 100: 90 90 90 90.0 Incorrect input, re-enter valid grades: 90 90 90 90 Entered grades are: 90, 90, 90, 90 Student Average: 90 . 00 Document your code, use proper prompts, format outputs as shown, use sound coding practices we learned thus far, do not hard code inputs, and allow program re-runs with different inputs

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions