Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- class Student {
- String name = "NULL";
- int batch = 0;
- int roll_no = 0;
- }
- class Exam extends Student {
- static int marks1 = 0;
- static int marks2 = 0;
- static int marks3 = 0;
- static int marks4 = 0;
- static int marks5 = 0;
- static int marks6 = 0;
- InputStreamReader ir = new InputStreamReader(System.in);
- BufferedReader br = new BufferedReader(ir);
- void setdata() throws Exception {
- System.out.println("");
- System.out.print("ENTER NAME OF THE STUDENT :- ");
- name = br.readLine();
- System.out.print("ENTER BATCH :- ");
- batch = Integer.parseInt(br.readLine());
- System.out.print("ENTER THE ROLL NUMBER :- ");
- roll_no = Integer.parseInt(br.readLine());
- System.out.print("ENTER MARKS1 :- ");
- marks1 = Integer.parseInt(br.readLine());
- System.out.print("ENTER MARKS2 :- ");
- marks2 = Integer.parseInt(br.readLine());
- System.out.print("ENTER MARKS3 :- ");
- marks3 = Integer.parseInt(br.readLine());
- System.out.print("ENTER MARKS4 :- ");
- marks4 = Integer.parseInt(br.readLine());
- System.out.print("ENTER MARKS5 :- ");
- marks5 = Integer.parseInt(br.readLine());
- System.out.print("ENTER MARKS6 :- ");
- marks6 = Integer.parseInt(br.readLine());
- }
- }
- class Result extends Exam {
- void display() throws Exception {
- System.out.println("");
- System.out.println(" NAME OF THE STUDENT IS :- " + name);
- System.out.println(" BATCH IS :- " + batch);
- System.out.println(" THE ROLL NUMBER IS :- " + roll_no);
- System.out.println("");
- }
- public static void main(String s[]) throws java.io.IOException {
- int total = 0;
- float average = 0;
- try {
- Result obj = new Result();
- obj.setdata();
- obj.display();
- total = marks1 + marks2 + marks3 + marks4 + marks5 + marks6;
- System.out.println("TOTAL MARKS CALCULATED IS :-" + total);
- average = total / 6;
- System.out.println("AVERAGE MARKS CALCULATED IS :- " + average);
- } catch (Exception e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement