Advertisement
GazaIan

Untitled

Nov 24th, 2014
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.30 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class pgrm4 {
  4.  
  5.     public static void main(String[] args) {
  6.         // TODO Auto-generated method stub
  7.        
  8.         Scanner keyboard = new Scanner(System.in);
  9.        
  10.         double scores, as, bs, cs, ds, fs, total;
  11.        
  12.         as = 0;
  13.         bs = 0;
  14.         cs = 0;
  15.         ds = 0;
  16.         fs = 0;
  17.         total = 0;
  18.         high = 0;
  19.         low = 999;
  20.        
  21.         do
  22.         {
  23.             System.out.println("Enter a grade. Enter -1 when you are done.");
  24.            
  25.             scores = keyboard.nextDouble();
  26.            
  27.             if(scores > high)
  28.             {
  29.                 high = scores;
  30.             }
  31.             if(scores < low)
  32.             {
  33.                 low = scores;
  34.             }
  35.             if(scores >= 90) //This is a mega shitload of if else statements, all used to decide what letter grade the entered number should get.
  36.             {
  37.                 as++;
  38.                 total++;
  39.             }
  40.             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.
  41.             {
  42.                 bs++;
  43.                 total++;
  44.             }
  45.             else if(scores < 80 && scores >= 70)
  46.             {
  47.                 cs++;
  48.                 total++;
  49.             }
  50.             else if(scores < 70 && scores >= 60)
  51.             {
  52.                 ds++;
  53.                 total++;
  54.             }
  55.             else if (scores > 0)
  56.             {
  57.                 fs++;
  58.                 total++;
  59.             }
  60.         }while(scores > 0);
  61.         System.out.println("Total grades entered: " +total); //This line just outputs all the fun stuff up there.
  62.         System.out.println("A's entered :" +as); //and this one.
  63.         System.out.println("B's entered: " +bs); //and this one.
  64.         System.out.println("C's entered: " +cs); //and this one.
  65.         System.out.println("D's entered: " +ds); //and this one.
  66.         System.out.println("F's entered: " +fs); //you get the point.
  67.         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.
  68.         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.
  69.         System.out.println("Percentage of C's received: " +(cs/total*100));
  70.         System.out.println("Percentage of D's received: " +(ds/total*100));
  71.         System.out.println("Percentage of F's received: " +(fs/total*100)); // life struggle
  72.         System.out.println("Highest Score: " +high);
  73.         System.out.println("Lowest Score: " +low); //I redid this from my Mac so I didn't test it, but it should be the same
  74.     }
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement