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
What does syntax error mean :-;<br>explain briefly.<br><br>thankyou!
Alex Ar [27]
A syntax error is an error in the syntax of a sequence of characters or tokens that is intended to be written in a particular programming language. For compiled languages, syntax errors are detected at compile-time. A program will not compile until all syntax errors are corrected.
3 0
1 year ago
What are the limitations of the ASCII character set? State why it is limited in this way?
dedylja [7]
The problem with ASCII or extended ASCII is that the ASCII system can only represent up to 128 (or 256 for EASCII) different characters. The limitation on the number of character sets means representing character sets for several different language structures is not possible.
7 0
3 years ago
You are unpacking and setting up workstations
Anestetic [448]

Answer:

For setting up workstations in classrooms, one end of cables connected into the built in NIC and other end will be connected to a drop.

Explanation:

A drop will be used for connectivity in this case, which will work as connection point in a network. Drops are just like outlets in wall having  Ethernet Jacks where a network device or system can be plugged into it.

8 0
3 years ago
A personal idea is unique to the person who developed, discovered or created that idea.
kolbaska11 [484]
Yeah thats true! but what is the question? lol

5 0
3 years ago
Read 2 more answers
A rectangular range of cells with headings to describe the cells' contents is referred to as a?
Anastasy [175]

Answer:

Table

Explanation:

A table of information is a set of rows and columns. It is a way of displaying information.

For example if we want to organize the information in the rows and columns then we should make the table. These rows and columns are formed cells and cells gathers to make a table.

<em>A rectangular range of cells with headings to describe the cells' contents is referred to as a </em><em><u>Table.</u></em>

8 0
3 years ago
Other questions:
  • When a packet with the code is transmitted, it is received and processed by every machine on the network. this mode of operation
    12·1 answer
  • Is 49 greater than y? Which below is correct?
    12·1 answer
  • Which command would you use on a switch to enable management from a remote network?
    5·1 answer
  • Sally is editing her science report about living things. She needs to copy a paragraph from her original report.
    15·2 answers
  • Which of these statements describes the difference between binary and decimal numbers?
    11·2 answers
  • In the code that follows, window is a/an ____________________________. window.prompt("enter your name");
    5·1 answer
  • 6. According to camp policy, staff members need to be at least 23 years old to transport students. Dean now wants to determine h
    9·1 answer
  • Select the correct images Jane has to pick images that portray action photography. Which of these images would she pick? please
    9·1 answer
  • A folder is a collection of related of data is true or false​
    10·2 answers
  • Assume that two students are trying to register for a course in which there is only one open seat. What component of a database
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!