Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1 Description For this lab you will write a Java program to prompt the user for a single double value between 0.0 and 100.0.

Exercise 1 Description

For this lab you will write a Java program to prompt the user for a single double value between 0.0 and 100.0. Your program should display a message indicating the letter grade that corresponds to this value (see the table below). If the user enters a number of out range (less than 0 or more than 100), your program should report an error. In the ClosedLab04 folder, create a new Java program named Lab04a.java for this problem.

Exercise 1 Sample Output

This is a sample transcript of what your program should do. Items in bold are user input and should not be put on the screen by your program. Enter a grade value between 0 and 100: 93 You received an A A second run of the code might give this output: Enter a grade value between 0 and 100: 87.6 You received a B+ Your code should provide an error message if the number goes out of range: Enter a grade value between 0 and 100: 150.7 ERROR: Grade must be between 0 and 100 Or: Enter a grade value between 0 and 100: -10 ERROR: Grade must be between 0 and 100 Your code should implement the following table, and provide a correct response for any number the user chooses. For grade values on a boundary, always assign the highest grade (for example, a 93 is an A, a 90 is an A-, an 87 is a B+, etc.):

Grade Range Letter Grade
93.0-100.0 A
90.0-93.0 A-
87.0-90.0 B+
83.0-87.0 B
80.0-83.0 B-
77.0-80.0 C+
73.0-77.0 C
70.0-73.0 C-
67.0-70.0 D+
60.0-67.0 D
0.0-60.0 E

NOTE: For this assignment you may want to use the Double.parseDouble() method. The code below shows an example of how to use this method to convert a String into an double. String input = "12.34"; double inputDbl = Double.parseDouble(input); // inputDbl now has a value of 12.34

Exercise 2 Description

For this lab you will write a Java program to prompt the user to enter a time in HH:MM AM/PM format. Your program will break this string up into hours, minutes and AM or PM and then convert this to an integer in military time. Create a new Java program named Lab04b.java for this problem.

Exercise 2 Sample Output

This is a sample transcript of what your program should do. Items in bold are user input and should not be put on the screen by your program. Enter a time in HH:MM AM/PM format: 2:34 PM Time in military time is: 1434 A second run of this code might produce the following output: Enter a time in HH:MM AM/PM format: 1:46 AM Time in military time is: 146 NOTE: For this exercise you should assume that the input will be properly formatted with an hour between 1 and 12, then a colon (':'), then minutes between 00 and 59, then a space and either the token 'AM' or 'PM'. Your code should take the line from the user as a string and turn it into an integer value. The table below shows standard time values and their corresponding military time values. Note that for this assignment you do not need to format your output to include leadings zeroes for times less than 1000.

Regular Time Military Time Regular Time Military Time
Midnight 0000 Noon 1200
1:00 AM 0100 1:00 PM 1300
2:00 AM 0200 2:00 PM 1400
3:00 AM 0300 3:00 PM 1500
4:00 AM 0400 4:00 PM 1600
5:00 AM 0500 5:00 PM 1700
6:00 AM 0600 6:00 PM 1800
7:00 AM 0700 7:00 PM 1900
8:00 AM 0800 8:00 PM 2000
9:00 AM 0900 9:00 PM 2100
10:00 AM 1000 10:00 PM 2200
11:00 AM 1100 11:00 PM 2300

NOTE 2: For this assignment you will need to use the Integer.parseInt() method. The code below shows an example of how to use this method to convert a String into an integer. String input = "123"; int inputInt = Integer.parseInt(input); // inputInt now has a value of 123

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_2

Step: 3

blur-text-image_3

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

The Power Of Numbers In Health Care A Students Journey In Data Analysis

Authors: Kaiden

1st Edition

8119747887, 978-8119747887

More Books

Students also viewed these Databases questions

Question

What do you think of the MBO program developed by Drucker?

Answered: 1 week ago