Question: Using Java programming to answer it. (a) The method enterScore(String message) of a class Exam has already been written and you can use it directly.
Using Java programming to answer it.
(a) The method enterScore(String message) of a class Exam has already been written and you can use it directly. It prints the string message, which asks for user input, and returns the input as a string. Write a Java program segment (assuming it is in a method of the class Exam) using the method enterScore() to display the message "Input a non-negative integer score" and get the user input. You should ask again until the input is non-negative. Finally the score should be stored in a variable score (of type int). You can assume the user always input a valid integer.
(b) Write another Java program segment assigning a suitable character to the variable grade (of type char) according to the following conditions: Condition Grade assigned
score >= 85 'A'
40 <= score < 85 'P'
score < 40 'F'
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
