Question

In: Computer Science

Write a java code that gets student test scores from the user. Each test score will...

Write a java code that gets student test scores from the user. Each test score will be an integer in the range 0 to 100. Input will end when the user enters -1 as the input value. After all score have been read, display the number of students who took the test, the minimum score, the maximum score, the average score (with decimal point, and the number of A where an A is a score in the range 90-100.

Solutions

Expert Solution

//MinMaxAvgScore.java
import java.util.Scanner;

public class MinMaxAvgScore {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        int min = Integer.MAX_VALUE,max = Integer.MIN_VALUE,sum = 0;
        double avg;
        int i = 0, gradeA = 0;

        System.out.print("Enter score in the range 0 to 100: ");
        n=sc.nextInt();

        while (n!=-1){
            i++;
            if(min>n){
                min = n;
            }
            if(max<n){
                max = n;
            }
            sum += n;
            if(n>90){
                gradeA += 1;
            }

            System.out.print("Enter score in the range 0 to 100: ");
            n=sc.nextInt();
        }
        if(i>0) {
            avg = sum / i;
            System.out.println("Number of tests: "+i);
            System.out.println("Minimum score: "+min);
            System.out.println("Maximum score: "+max);
            System.out.println("Average score: "+avg);
            System.out.println("Number of grade A scores: "+gradeA);
        }

    }
}


Related Solutions

Sections 7.1 Write a program that reads student scores, gets the best score, and the assigns...
Sections 7.1 Write a program that reads student scores, gets the best score, and the assigns grades based on the following scheme: Grade is A if scores is >= best - 10; Grade is B if scores is >= best - 20; Grade is C if scores is >= best - 30; Grade is D if scores is >= best - 40; Grade is F otherwise. The program prompts the user to enter the total number of students, then prompts...
in java Write an application that gets two numbers from the user and prints the sum,...
in java Write an application that gets two numbers from the user and prints the sum, product, difference and quotient of the two numbers in a GUI.
(JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students...
(JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students identified by rows and test scores identified by columns. Ask the user for the number of students and for the number of tests (which will be the size of the two-dimensional array). Populate the array with user input (with numbers in {0, 100} for test scores). Assume that a score >= 60 is a pass for the below. Then, write methods for: Computing the...
Instructions Write a Java program that asks the user t enter five test scores. The program...
Instructions Write a Java program that asks the user t enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: * calcAverage -- This method should accept five test scores as arguments and return the average of the scores. * determineGrade -- This method should accept a test score as an argument and return a letter grade for the score, based on the following...
Write Java code that allows a user to repeatedly enter numbers. Each time the user enters...
Write Java code that allows a user to repeatedly enter numbers. Each time the user enters a number, the program should print out the average of the last 3 numbers (or all numbers if 3 or less have been entered). I would like a detailed explanation so that a beginner level Java programmer could understand.
Can you write code or class in java accepting from the user a + b as...
Can you write code or class in java accepting from the user a + b as a string and accepting their value from the user and the out but will be the sum of the variables.
Write a java code to ask the user for a string, and assuming the user enters...
Write a java code to ask the user for a string, and assuming the user enters a string containing character "a", your java program must convert all "a" to "b" in the string so for example if user types : "AMAZON" , your program must convert it to "BMBZON" the driver program must ask : enter a string containing "a" or "A" --------- (user enters string) then it should say; HERE IS YOUR NEW STRING ---------- (string with all a's...
Write a java code to (A) Enter the number of children, (B) Insert names from user,...
Write a java code to (A) Enter the number of children, (B) Insert names from user, (C) Print these names. upload source code with a screenshotfor output in one file with cover page
C LANGUAGE Ask user how many scores there are, then ask for each score. Then calculate...
C LANGUAGE Ask user how many scores there are, then ask for each score. Then calculate the average score and scores below 60. Then display the average score and number of scores below 60
Write an application that allows a user to enter any number of student quiz scores, as...
Write an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than 0 or more than 10, display Score must be between 10 and 0 and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT