Advertisement
JackHoughton00

Percent Passing

Mar 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. package percentpassing;
  2. import java.util.Scanner;
  3. public class PercentPassing {
  4.  
  5. public static void main(String[] args) {
  6. final int SENTINEL = 0;
  7. int newValue;
  8. int numValues = 0;
  9. int passing = 0;
  10. double avg;
  11. Scanner input = new Scanner(System.in);
  12. System.out.print("Average scores above 70%");
  13. System.out.print("\nEnter a score above 70%("+SENTINEL+ "to quit):");
  14. newValue = input.nextInt();
  15. while (newValue !=SENTINEL){
  16. numValues += 1;
  17. if (numValues >= 70){
  18. passing +=1;
  19. }
  20. System.out.print("Enter a score("+SENTINEL+"to quit):");
  21. numValues = input.nextInt();
  22. }
  23. input.close();
  24. avg = (double) passing / (double)numValues;
  25. System.out.println("Average is "+avg);
  26. } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement