Friday 29 June 2012

java program that take input of student details and subject marks and generate marksheet(result) for student.

import java.io.*;
class marks
    {
        int sub1,sub2,sub3,sub4,sub5,sub6,tot;
        float percentage;
        String stud_name,sid,g;
        public marks(String stud_name,String sid,int sub1,int sub2,int sub3,int sub4,int sub5,int sub6,int tot,float percentage)
            {
                this.stud_name=stud_name;
                this.sid=sid;
                this.sub1=sub1;
                this.sub2=sub2;
                this.sub3=sub3;   
                this.sub4=sub4;
                this.sub5=sub5;
                this.sub6=sub6;
                this.tot=tot;
                this.percentage=percentage;
            }



        int tot(int sub1,int sub2,int sub3,int sub4,int sub5,int sub6)
            {
                return sub1+sub2+sub3+sub4+sub5+sub6;
            }
        float percentage(int sub1,int sub2,int sub3,int sub4,int sub5,int sub6)
            {
                return (sub1+sub2+sub3+sub4+sub5+sub6)/6;
            }
        String grade()
            {     
                String g;
                if(percentage>=70)
                    {
                     g="Distiction";
                    }   
                else if(percentage>=60 && percentage<70)
                    {
                    g="First";
                    }
                else if(percentage>=50 && percentage<60)
                    {
                    g="Second";
                    }
                else if(percentage>=40 && percentage<50)
                    {
                    g="Pass";
                    }
                else
                    {
                    g="Fail";
                    }           
                return g;               
            }
    }
class Marksheets
    {   
       public static void main(String args[]) throws IOException
          {   
        String s,stud_name,sid;
        String g;
        int sub1,sub2,sub3,sub4,sub5,sub6,tot;
        float percentage;   
        System.out.println("Enter the name:");

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          //s=br.readLine();
        System.out.println("Enter the id:");
        sid=br.readLine();
       
        System.out.println("Enter the 501 marks:");
        s=br.readLine();
        sub1=Integer.parseInt(s);
       
        System.out.println("Enter the 502 marks:");
        s=br.readLine();
        sub2=Integer.parseInt(s);
       
        System.out.println("Enter the 503 marks: ");
        s=br.readLine();
        sub3=Integer.parseInt(s);
       
        System.out.println("Enter the 504 marks:");
        s=br.readLine();
        sub4=Integer.parseInt(s);
       
        System.out.println("Enter the 505 marks: ");
        s=br.readLine();
        sub5=Integer.parseInt(s);
       
        System.out.println("Enter the 506 marks:");
        s=br.readLine();
        sub6=Integer.parseInt(s);

        marks m = new marks(sid,stud_name,sub1,sub2,sub3,sub4,sub5,sub6,tot,percentage);       


        int a1 = m.tot( sub1,sub2,sub3,sub4,sub5,sub6);   
            float per = m.percentage(sub1,sub2,sub3,sub4,sub5,sub6);
        m.grade();
   
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        System.out.println("\t\tFUTURES OF STUDENT");
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        System.out.println("STUDENT NAME:-"+m.stud_name);
        System.out.println("STUDENT ID:-"+m.sid);
        System.out.println("\tTOTAL MARKS="+a1);
        System.out.println("\tPERCENTAGE="+per);
        System.out.println("\tGRADE:-"+m.g);
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
         }   
    }   
       

No comments:

Post a Comment