Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TestScore.java A very simple driver class which you can use as a base. The problem description is to obtain a single valid test score from

TestScore.java A very simple driver class which you can use as a base. The problem description is to obtain a single valid test score from the user. Valid means that it is a floating point (or integer) in its format, and that this number is in the range [0, 100].

Your job is to add the necessary components to the program file so that the specification above is met. Suggested components:

a String variable

a boolean variable

a do loop

an if statement

a try and a catch block

6.Rememberallofthenumericparsemethodsthrowawhenagiven strings format does not match the typesform.

Your finished program will produce output / runs similar to:

Please enter a test score [0, 100] : -1

TestScore.java A very simple driver class which you can use as a base. The problem description is to obtain a single valid test score from the user. Valid means that it is a floating point (or integer) in its format, and that this number is in the range [0, 100].

Your job is to add the necessary components to the program file so that the specification above is met. Suggested components:

a String variable

a boolean variable

a do loop

an if statement

a try and a catch block

Remember all of the numeric parse methods throw a NumberFormatException when a given strings format does not match the types form.

Your finished program will produce output / runs similar to:

Please enter a test score [ 0,100] : -1

Please enter a test score [0,100]: 101

Please enter a test score [0,100]: hgwells

Please enter a numeric test score [0,100]: 78.5

The Valid score entered was 78.5 And must not "crash" on invalid input

Make sure that your program runs without errors or warnings.

Run your program enough times to verify its correctness.

Here is testscore:

import java.util.Scanner;

public class TestScore { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); double score = -1; System.out.print("Please enter a test score [0, 100] : "); System.out.println("The valid score entered was " + score); } }

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

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions