Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » Homework HelpRSS Feeds

Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students marks

Posted By: Easy Tutor     Category: Java     Views: 13583

Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students who have obtained marks
a) In the range 80 to 100.
b) In the range 60 to 79.
c) In the range 40 to 59 and
d) In the range 0 to 39.
The program should use a minimum number of if statements.

Code for Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students marks in Java

import java.io.*;

class Marks 
{
    publicstaticvoid main(String args[]) 
    {
           int data[] = newint[10];
           int counter,index;
           String str;
           

         try{
        BufferedReader obj = new BufferedReader(new InputStreamReader

(System.in));
                 for(counter=0;counter<10;counter++)
                   {
                         System.out.print("Enter Marks of Roll No :- 

"+(counter+1)+"   --> ");
                         System.out.flush();
                         str=obj.readLine();
                         data[counter]=Integer.parseInt(str);
                    }

            //logic begins       for(counter=0;counter<10;counter++)
                        {
                           System.out.println("\nMarks of 

Rollno : "+(counter+1)+" is  :     "+data[counter]);
                            index=(int)(data[counter]/10);
                           switch(index)
                           {
                                case 10:
                                case 9:
                                case 8: 
                                        

System.out.println("Roll No : -  "+(counter+1)+"----->GRADE  A");
                                        break;
                                case 7:
                                case 6:
                                        

System.out.println("Roll No : -  "+(counter+1)+"----->GRADE  B");
                                        break;
                                case 5:
                                case 4:
                                        

System.out.println("Roll No : -  "+(counter+1)+"----->GRADE  C");
                                        break;
                                case 3:
                                case 2:
                                case 1:
                                case 0:
                                    

System.out.println("Roll No : -  "+(counter+1)+"----->FAIL");
                                }
                      }
                    }
                catch (Exception e)  {}
    }
}
  
Share: 



Easy Tutor
Easy Tutor author of Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students marks is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!