Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class pgrm4 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner keyboard = new Scanner(System.in);
- double scores, as, bs, cs, ds, fs, total;
- as = 0;
- bs = 0;
- cs = 0;
- ds = 0;
- fs = 0;
- total = 0;
- high = 0;
- low = 999;
- do
- {
- System.out.println("Enter a grade. Enter -1 when you are done.");
- scores = keyboard.nextDouble();
- if(scores > high)
- {
- high = scores;
- }
- if(scores < low)
- {
- low = scores;
- }
- if(scores >= 90) //This is a mega shitload of if else statements, all used to decide what letter grade the entered number should get.
- {
- as++;
- total++;
- }
- else if(scores < 90 && scores >= 80) //The program takes the inputted number, compares it to all these statements, and increases it in which ever is true.
- {
- bs++;
- total++;
- }
- else if(scores < 80 && scores >= 70)
- {
- cs++;
- total++;
- }
- else if(scores < 70 && scores >= 60)
- {
- ds++;
- total++;
- }
- else if (scores > 0)
- {
- fs++;
- total++;
- }
- }while(scores > 0);
- System.out.println("Total grades entered: " +total); //This line just outputs all the fun stuff up there.
- System.out.println("A's entered :" +as); //and this one.
- System.out.println("B's entered: " +bs); //and this one.
- System.out.println("C's entered: " +cs); //and this one.
- System.out.println("D's entered: " +ds); //and this one.
- System.out.println("F's entered: " +fs); //you get the point.
- System.out.println("Percentage of A's received: " +(as/total*100)); //For the sake of simplicity, the percent equations are done right in the output statement to save time and space.
- System.out.println("Percentage of B's received: " +(bs/total*100)); //of course, there are other place I could also have saved space. This just seemed cool.
- System.out.println("Percentage of C's received: " +(cs/total*100));
- System.out.println("Percentage of D's received: " +(ds/total*100));
- System.out.println("Percentage of F's received: " +(fs/total*100)); // life struggle
- System.out.println("Highest Score: " +high);
- System.out.println("Lowest Score: " +low); //I redid this from my Mac so I didn't test it, but it should be the same
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement