fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. try(Scanner Score1 = new Scanner(System.in))
  13. {
  14. //Marks are in range of 0-100
  15. float curNum, max = -1, min = 101, sum = 0, sumsq = 0;
  16. boolean flg = true;
  17.  
  18. while(flg)
  19. {
  20. System.out.println("Enter a score [negative score to quit]: ");
  21. curNum = Score1.nextFloat();
  22. if(curNum<0) break;
  23. if(max < curNum) max = curNum;
  24. if(min > curNum) min = curNum;
  25. sum += curNum;
  26. sumsq += (curNum*curNum);
  27. }
  28. System.out.printf("Minimun Score = %.0f\n", min);
  29. System.out.printf("Maximum Score = %.0f\n", max);
  30. }
  31.  
  32. }
  33. }
Success #stdin #stdout 0.08s 4386816KB
stdin
1 2 3 -1
stdout
Enter a score [negative score to quit]: 
Enter a score [negative score to quit]: 
Enter a score [negative score to quit]: 
Enter a score [negative score to quit]: 
Minimun Score = 1
Maximum Score = 3