Wednesday 26 August 2020

Java program to process result

PROGRAM

import java.io.*;

class StudentExam
{
    String name;
    String regno;
    double CIA1, CIA2,assgn,quiz,ext_mark,int_mark;
    String result;

  StudentExam()
  {
       name="\0";
       regno="\0";
       CIA1=CIA2=assgn=quiz=ext_mark=int_mark=0;
       result="\0";
  }

  StudentExam(String n,String r,double c1,double c2,double a,double qz,double e)
  {
       name=n;
       regno=r;
       CIA1=c1;
       CIA2=c2;
       assgn=a;
       quiz=qz;
       ext_mark=e;
  }
   
  void getData() throws IOException
  {
      BufferedReader x=new BufferedReader(new InputStreamReader(System.in));
      System.out.println("Enter name, regno");
      name=x.readLine();
      regno=x.readLine();
      System.out.println("Enter CIA1(50), CIA2(50), Assig(15), quiz(15)");
      CIA1=Double.parseDouble(x.readLine());
      CIA2=Double.parseDouble(x.readLine());
      assgn=Double.parseDouble(x.readLine());
      quiz=Double.parseDouble(x.readLine());
      System.out.println("Enter Sem_mark(50)");
      ext_mark=Double.parseDouble(x.readLine());
  }

  void getResult()
  {
       double cia = (CIA1+CIA2) * 70 /100;
       int_mark = (cia + assgn+quiz)/2;
       if  (ext_mark >= 20)
       {
           if ((int_mark + ext_mark) >=40)
              result="PASS";
           else
              result = "FAIL";
       }
       else
           result="FAIL";
  } 
  
  void display()
  {
       System.out.println("Student details");
       System.out.println("--------------------");
       System.out.println("Name = "+name);
       System.out.println("RegNo = "+regno);
       System.out.println("CIA1 = "+CIA1 +", CIA2 = "+CIA2);
       System.out.println("Assignment = "+assgn+", Quiz = "+quiz);
       System.out.println("Internal Mark = "+int_mark);
       System.out.println("External Mark = "+ext_mark);
       System.out.println("Result = "+result);
  }
}

class StudentResult
{
   public static void main(String args[]) throws IOException
   {
       StudentExam s1=new StudentExam();
       s1.getData();
       s1.getResult();
       s1.display();
    }
}

OUTPUT
Enter name, regno
Safi
33
Enter CIA1(50), CIA2(50), Assig(15), quiz(15)
20
20
15
10
Enter Sem_mark(50)
25

Student details
------------------
Name = Safi
RegNo = 33
CIA1 = 20.0, CIA2 = 20.0
Assignment = 15.0, Quiz = 10.0
Internal Mark = 26.5
External Mark = 25.0
Result = PASS

No comments:

Post a Comment