Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Scanner;
- public class TestScoreStatistics {
- public static void main(String[] args)
- {
- int max=0;
- int min=999;
- int avg=0;
- int count=0;
- int sum=0;
- int num;
- Scanner scan=new Scanner(System.in);
- System.out.println("Please input test scores with values between 0-100.
- Enter 999 to finish.");
- num=scan.nextInt();
- int temp=num;
- do
- {
- if(num==999)
- System.exit(0);
- if(num>=0 && num<=100)
- {
- count++;
- sum+=num;
- if(num>max )
- max=num;
- if(num<min)
- min=num;
- } }
- while((num=scan.nextInt())!=999);
- System.out.println("Test Statistics:");
- System.out.println("Number of tests: "+count);
- System.out.println("Lowest: "+min);
- System.out.println("Highest: "+max);;
- System.out.printf("Average: " + sum/count); } }
Add Comment
Please, Sign In to add comment