Daryan997

Homework - Programming

Sep 12th, 2020
1,360
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package javaapplication50;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class JavaApplication50 {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.         System.out.println("Enter grade or -1 to quit:");
  10.         int number = 0;
  11.         int sum = 0;
  12.         int students = 1;
  13.         double average = 0;
  14.         int freq50 = 0;
  15.         int freq50to60 = 0;
  16.         int freq60to70 = 0;
  17.         int freq70to80 = 0;
  18.         int freq80to90 = 0;
  19.         int freq90to100 = 0;
  20.         while (number != -1) {
  21.             number = scanner.nextInt();
  22.             if (number < 50 && number >= 0) {
  23.                 freq50++;
  24.             } else if (number >= 50 && number < 60) {
  25.                 freq50to60++;
  26.             } else if (number >= 60 && number < 70) {
  27.                 freq60to70++;
  28.             } else if (number >= 70 && number < 80) {
  29.                 freq70to80++;
  30.             } else if (number >= 80 && number < 90) {
  31.                 freq80to90++;
  32.             } else if (number >= 90 && number <= 100) {
  33.                 freq90to100++;
  34.             }
  35.             if (number != -1) {
  36.                 sum = sum + number;
  37.                 students++;
  38.             }
  39.         }
  40.         students--;
  41.         average = sum / students;
  42.         System.out.println("Marks\t\tFrequency");
  43.         System.out.println("below 50\t" + freq50);
  44.         System.out.println("50-60\t\t" + freq50to60);
  45.         System.out.println("60-70\t\t" + freq60to70);
  46.         System.out.println("70-80\t\t" + freq70to80);
  47.         System.out.println("80-90\t\t" + freq80to90);
  48.         System.out.println("90-100\t\t" + freq90to100);
  49.         System.out.println("****************************");
  50.         System.out.println("Class Average is " + average);
  51.     }  
  52. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×