ABaDy1996

Mid2

Nov 5th, 2020
958
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2. public class exam {
  3.     public static void main(String[] args){
  4.         Scanner input = new Scanner(System.in);
  5.         int n,d, min=50,max=0,avg,total=0;
  6.         System.out.print("Enter the number of days: ");
  7.         n = input.nextInt();
  8.         for(int i=1;i<=n;i++){
  9.             System.out.print("Recovered day ("+i+") : ");
  10.             d = input.nextInt();
  11.             total += d;
  12.             if(d>max) max=d;
  13.             if(d<min) min=d;
  14.         }
  15.         avg = total/n;
  16.         System.out.println("         10   20   30  40   50");
  17.         System.out.println("         |    |     |   |    |");
  18.         System.out.println("     ----x----x----x----x----x");
  19.         print_bar("AVG",avg);
  20.         print_bar("MIN",min);
  21.         print_bar("MAX",max);
  22.     }
  23.     public static void print_bar(String title,int number){
  24.         System.out.print(title +" :");
  25.         for(int x=1;x<=number/2;x++){
  26.             System.out.print("*");
  27.         }
  28.         System.out.println();
  29.     }
  30. }
  31.  
RAW Paste Data