Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package percentpassing;
- import java.util.Scanner;
- public class PercentPassing {
- public static void main(String[] args) {
- final int SENTINEL = 0;
- int newValue;
- int numValues = 0;
- int passing = 0;
- double avg;
- Scanner input = new Scanner(System.in);
- System.out.print("Average scores above 70%");
- System.out.print("\nEnter a score above 70%("+SENTINEL+ "to quit):");
- newValue = input.nextInt();
- while (newValue !=SENTINEL){
- numValues += 1;
- if (numValues >= 70){
- passing +=1;
- }
- System.out.print("Enter a score("+SENTINEL+"to quit):");
- numValues = input.nextInt();
- }
- input.close();
- avg = (double) passing / (double)numValues;
- System.out.println("Average is "+avg);
- } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement