Advertisement
CreateWithChirag

Question_8

Apr 11th, 2022
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.94 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. class Student {
  4.     String name = "NULL";
  5.     int batch = 0;
  6.     int roll_no = 0;
  7. }
  8.  
  9. class Exam extends Student {
  10.     static int marks1 = 0;
  11.     static int marks2 = 0;
  12.     static int marks3 = 0;
  13.     static int marks4 = 0;
  14.     static int marks5 = 0;
  15.     static int marks6 = 0;
  16.     InputStreamReader ir = new InputStreamReader(System.in);
  17.     BufferedReader br = new BufferedReader(ir);
  18.  
  19.     void setdata() throws Exception {
  20.         System.out.println("");
  21.         System.out.print("ENTER NAME OF THE STUDENT :- ");
  22.         name = br.readLine();
  23.         System.out.print("ENTER BATCH :- ");
  24.         batch = Integer.parseInt(br.readLine());
  25.         System.out.print("ENTER THE ROLL NUMBER :- ");
  26.         roll_no = Integer.parseInt(br.readLine());
  27.         System.out.print("ENTER MARKS1 :- ");
  28.         marks1 = Integer.parseInt(br.readLine());
  29.         System.out.print("ENTER MARKS2 :- ");
  30.         marks2 = Integer.parseInt(br.readLine());
  31.         System.out.print("ENTER MARKS3 :- ");
  32.         marks3 = Integer.parseInt(br.readLine());
  33.         System.out.print("ENTER MARKS4 :- ");
  34.         marks4 = Integer.parseInt(br.readLine());
  35.         System.out.print("ENTER MARKS5 :- ");
  36.         marks5 = Integer.parseInt(br.readLine());
  37.  
  38.         System.out.print("ENTER MARKS6 :- ");
  39.         marks6 = Integer.parseInt(br.readLine());
  40.     }
  41. }
  42.  
  43. class Result extends Exam {
  44.     void display() throws Exception {
  45.         System.out.println("");
  46.         System.out.println(" NAME OF THE STUDENT IS :- " + name);
  47.         System.out.println(" BATCH IS :- " + batch);
  48.         System.out.println(" THE ROLL NUMBER IS :- " + roll_no);
  49.         System.out.println("");
  50.     }
  51.  
  52.     public static void main(String s[]) throws java.io.IOException {
  53.         int total = 0;
  54.         float average = 0;
  55.         try {
  56.             Result obj = new Result();
  57.             obj.setdata();
  58.             obj.display();
  59.             total = marks1 + marks2 + marks3 + marks4 + marks5 + marks6;
  60.             System.out.println("TOTAL MARKS CALCULATED IS :-" + total);
  61.             average = total / 6;
  62.             System.out.println("AVERAGE MARKS CALCULATED IS :- " + average);
  63.  
  64.         } catch (Exception e) {
  65.         }
  66.     }
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement