1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Klio2033 [76]
3 years ago
15

Implement a Java program using simple console input & output and logical control structures such that the program prompts th

e user to enter 5 integer scores between 0 to 100 as inputs and does the following tasks For each input score, the program determines whether the corresponding score maps to a pass or a fail. If the input score is greater than or equal to 60, then it should print "Pass", otherwise, it should print "Fail". After the 5 integer scores have been entered, the program counts the total number of passes as well as the total number of failures and prints those 2 count values with appropriate messages like "Total number of passes is: " & "Total number of failures is: ". After the 5 integer scores have been entered, the program finds the highest score as well as the lowest score and prints those 2 values with appropriate messages like "Highest score is: " & "Lowest score is: ". The program checks whether an input score is a number between 0 - 100 or not. If the input score value is otherwise or outside the above range, then it prints the error message saying "Invalid score" and prompts the user for valid input.
Computers and Technology
1 answer:
miss Akunina [59]3 years ago
5 0

Answer:

  1. import java.util.Scanner;
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        int pass = 0;
  5.        int fail = 0;
  6.        int highest = 0;
  7.        int lowest = 100;
  8.        int counter = 0;
  9.        Scanner input = new Scanner(System.in);
  10.        while(counter < 5){
  11.            System.out.print("Input a score between 0 to 100: ");
  12.            int score = input.nextInt();
  13.            while(score < 0 || score > 100){
  14.                System.out.println("Invalid score.");
  15.                System.out.print("Input a score between 0 to 100: ");
  16.                score = input.nextInt();
  17.            }
  18.            if(score >= 60 ){
  19.                System.out.println("Pass");
  20.                pass++;
  21.            }else{
  22.                System.out.println("Fail");
  23.                fail++;
  24.            }
  25.            if(highest < score ){
  26.                highest = score;
  27.            }
  28.            if(lowest > score){
  29.                lowest = score;
  30.            }
  31.            counter++;
  32.        }
  33.        System.out.println("Total number of passes is: " + pass);
  34.        System.out.println("Total number of failures is: " + fail);
  35.        System.out.println("Highest score is: " + highest);
  36.        System.out.println("Lowest score is: " + lowest);
  37.    }
  38. }

Explanation:

Firstly, declare the necessary variables and initialize them with zero (Line 4-8). Next create a Scanner object to get user input for score (Line 10). Create a while loop by using the counter as limit (Line 12). In the while loop, prompt user to input a number between 1 - 100 (Line 13-14). Create another while loop to check the input must be between 1 - 100 or it will print invalid message and ask for user input again (Line 15-19).

Next, create an if-else statement to check if the current score is equal or above 60. If so print pass if not print fail (Line 21-27). At the same time increment the fail and pass counter.

Create another two if statement to get the current highest and lowest score and assign them to highest and lowest variables, respectively (Line 29-35).

Increment the counter by one before proceeding to the next loop to repeat the same process (Line 37).

At last, print the required output after finishing the while loop (Line 40-43).

You might be interested in
Gunther is filling in his own input mask. He wants to format the Social Security numbers of his clients. The field must contain
a_sh-v [17]
Last one I am not sure they
3 0
3 years ago
Add an array, which will store the most recent 5 recent transactions. For the array, add an insert function which will store the
Vika [28.1K]

The answer & explanation for this question is given in the attachment below.

Download docx
4 0
3 years ago
What is a benefit of naming cells and ranges?
Sholpan [36]

Answer:

Using names in formulas makes it clearer to see what the function is.

Explanation:

Just answered this in my online course.

8 0
3 years ago
Read 2 more answers
An 18 year old female is preparing to go to college in the Fall. She received the 1st dose of HPV and her booster dose of Mening
Elenna [48]

Answer: No, you will not have to determine the exact vaccine that caused the fever and rash. The CDC will determine that information.

Explanation:

To report a vaccine reaction to VAERS you just have to list the symptoms and reactions that were caused after getting a vaccine. The form that is needed to fill out a VAERs can be found on the CDC website. The person filling out the form will need to know the who, when, where, and how of the injury or symptom.

After the form has been received the patient will be contacted and their symptoms will be monitored. Some of the most common reactions after getting a vaccine are;

  • swelling
  • pain
  • redness
  • rash

4 0
3 years ago
Create a variable total of type Double set to 0. Then loop through the dictionary, and add the value of each integer and double
svp [43]

Answer:

total = 0.0

for x in dictionary.values():

   if x == str(x):

       total += 1

   elif x is bool:

       total += 2 if x is True else total -3

   else:

       total += x

print( total )

Explanation:

The python source code defines a variable 'total' and iterates through a dictionary and adds its values to the total variable. Finally, the total value is printed.

6 0
3 years ago
Other questions:
  • Assume a 8x1 multiplexer’s data inputs have the following present values: i0=0, i1=0, i2=0, i3=0, i4=0, i5=1, i6=0, i7=0. What s
    8·1 answer
  • Create a class CitiesAndCountries with at least three methods: class CitiesAndCountries: def add_country(self, country_name): ""
    7·1 answer
  • Si han visto el anime death note esta chido si no lo han visto veanlo es bien vacano
    6·1 answer
  • Which of these are correctly formatted python dictionaries? Check all that apply.
    5·2 answers
  • The following statement should determine if count is within the range of 0 through
    5·1 answer
  • What is the best Genshin impact ship? My favorite is Xiao x Lumine. Put yours bellow.
    13·2 answers
  • A human interest story is an example of hard news.<br> O True<br> O False HEL
    15·1 answer
  • True or False? You should never move an injured person.<br> True<br> False
    6·1 answer
  • What can be changed when a style is modified?
    5·2 answers
  • ____________________ is the use of an algorithm to scramble data into a format that can be read only by reversing the algorithm.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!