Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » Homework HelpRSS Feeds

Program to read rollno, marks of sub1,sub2 and sub3 and on basis of that display result

Posted By: Easy Tutor     Category: Java     Views: 20559

Write a program to read rollno, marks of sub1,sub2 and sub3 and on basis of that find

a) Total marks obtained by each student
b) The highest marks in each subject and the rollno of the student who secured it.
c) The student who obtained the highest total marks.

Code for Program to read rollno, marks of sub1,sub2 and sub3 and on basis of that display result in Java

import java.io.*;

class StudDetail
{
       int RollNo;
}

class StudMarks extends StudDetail
{
            float sub1;
            float sub2;
            float sub3;
            float TotalMarks;

            void getdata()
            {
                  System.out.println("\nRecording Entry");
                  try{
                      BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));
                      String sRNo,sSub1,sSub2,sSub3;
                      
                      System.out.print("Enter Roll No : ");
                      System.out.flush();
                      sRNo=obj.readLine();
                      RollNo=Integer.parseInt(sRNo);

                      System.out.print("Enter Marks for Subject 1 : ");
                      System.out.flush();
                      sSub1=obj.readLine();
                      sub1=Float.parseFloat(sSub1);
  
                      System.out.print("Enter Marks for Subject 2 : ");
                      System.out.flush();
                      sSub2=obj.readLine();
                      sub2=Float.parseFloat(sSub2);

                      System.out.print("Enter Marks for Subject 3 : ");
                      System.out.flush();
                      sSub3=obj.readLine();
                      sub3=Float.parseFloat(sSub3);

                      TotalMarks=sub1+sub2+sub3;
                      }
                      catch(Exception e){}
            }

            void display()
            {
                   System.out.println("\nDisplaying Record");
                   System.out.println("Roll No : "+RollNo);
                   System.out.println("Subject 1 : "+sub1);
                   System.out.println("Subject 2 : "+sub2);
                   System.out.println("Subject 3 : "+sub3);
                   System.out.println("Total Marks : "+TotalMarks);
           }

           void totalMarks()
           {
                  System.out.println("\nDisplaying Total Marks");
                  System.out.println("Roll No : "+RollNo);
                  System.out.println("Total Marks : "+TotalMarks);
            }
                        
}

class  StudentDatabase
{
    publicstaticvoid main(String args[]) 
    {
             System.out.println("\n=====STUDENT DATABASE=====\n");

             
            float HighMark_sub1;
            float HighMark_sub2;
            float HighMark_sub3;
            float StudHighMark;
            int No_of_stud=3,choice;
            String str;
            char c;

               try{
                    BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));
                    System.out.print("\nEnter number of Students  : ");
                    System.out.flush();
                    str=obj.readLine();
                    No_of_stud=Integer.parseInt(str);
                    StudMarks SMobj[]=new StudMarks[No_of_stud];

                    while(true)
                    {                             
                                    System.out.println("\nChoose your choice...");
                                    System.out.println("1) PASS ENTRY");
                                    System.out.println("2) DISPLAY ALL RECORDS");
                                    System.out.println("3) DISPLAY TOTAL MARKS for all students");
                                    System.out.println("4) DISPLAY HIGHEST MARKS in each subject");
                                    System.out.println("5) DISPLAY student who recived highest total marks");
                                    System.out.println("6) Exit ");
                                    System.out.print("Enter your choice : ");
                                    System.out.flush();
                                    str=obj.readLine();
                                    choice=Integer.parseInt(str);

                                    switch(choice)
                                    {
                                           case 1 :     for(int i=0;i<No_of_stud;i++)
                                                                     SMobj[i].getdata();
                                                              break;
                                            case 2 :    for(int i=0;i<No_of_stud;i++)
                                                                      SMobj[i].display();
                                                                break;
                                            case 3 :    for(int i=0;i<No_of_stud;i++)
                                                                       SMobj[i].totalMarks();
                                                                break;
                                            case 4 :     break;
                                            case 5 : break;
                                            case 6 : System.out.println("\nThanks for Visiting ....");
                                                           System.exit(1);
                                    }
                         }
                   }
                catch(Exception e){}              

    }
}
  
Share: 



Easy Tutor
Easy Tutor author of Program to read rollno, marks of sub1,sub2 and sub3 and on basis of that display result 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].

 
Bc Mulenga from Japan Comment on: Sep 04
the site was of help to me I have just keen interest in computer programing therefore I need a lot of assistance from your team so that my dream com true. My dream is to learn so that I empower others to keep abrest with technology.

Thank you so much for have been of great help to me

best wishes to you all

Mulenga

View All Comments