Guest User

Untitled

a guest
Mar 18th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class TestScoreStatistics {
  6. public static void main(String[] args)
  7. {
  8. int max=0;
  9. int min=999;
  10. int avg=0;
  11. int count=0;
  12. int sum=0;
  13. int num;
  14. Scanner scan=new Scanner(System.in);
  15. System.out.println("Please input test scores with values between 0-100.
  16. Enter 999 to finish.");
  17. num=scan.nextInt();
  18. int temp=num;
  19.  
  20.  
  21. do
  22. {
  23.  
  24. if(num==999)
  25. System.exit(0);
  26.  
  27.  
  28. if(num>=0 && num<=100)
  29. {
  30. count++;
  31. sum+=num;
  32.  
  33.  
  34. if(num>max )
  35.  
  36. max=num;
  37.  
  38.  
  39. if(num<min)
  40.  
  41. min=num;
  42. } }
  43.  
  44.  
  45.  
  46.  
  47.  
  48. while((num=scan.nextInt())!=999);
  49. System.out.println("Test Statistics:");
  50. System.out.println("Number of tests: "+count);
  51. System.out.println("Lowest: "+min);
  52. System.out.println("Highest: "+max);;
  53. System.out.printf("Average: " + sum/count); } }
Add Comment
Please, Sign In to add comment