Friday, December 23, 2011

Program to


import java.util.*;
public class Ch2Q29
{public static void main(String[] args)
      {int n, marks, counta = 0, countb = 0, countc= 0,countd = 0;
       Scanner kbd = new Scanner(System.in);
       System.out.print("How many students in the class: ");
       n = kbd.nextInt();
       for(int i = 1; i <= n ; i++)
       {System.out.print("Enter marks of student"+i+": ");
        marks = kbd.nextInt();
        switch((marks-1)/20)
        {case 4:counta++; break;
         case 3:countb++; break;
         case 2:countc++; break;
         case 1: case 0 :countd++; break;
         default: System.out.println("You are nuts\n");
        }
        }
        System.out.println("\nNo of students in the range of 81..100 are "+ counta);
        System.out.println("No of students in the range of 61..80 are "+ countb);
        System.out.println("No of students in the range of 41..60 are "+ countc);
        System.out.println("No of students in the range of 00..40 are "+ countd);
       
      }
}

No comments:

Post a Comment