Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Beginner
- {
- static protected String name;
- static protected int roll;
- protected int ans;
- private int base_score;
- Beginner(String name, int rollNo , int score)
- {
- this.name = name;
- this.roll = rollNo;
- ans = 0;
- base_score = score;
- }
- protected void Questions()
- {
- Scanner sc = new Scanner(System.in);
- System.out.println("Hi " + name +" Welcome to Beginner Level");
- System.out.println("What is 1 + 2 ?");
- ans = sc.nextInt();
- if(ans == 3) base_score += 20;
- System.out.println("What is 4 + 5 ?");
- ans = sc.nextInt();
- if(ans == 9) base_score += 20;
- System.out.println("What is 1 + 1 ?");
- ans = sc.nextInt();
- if(ans == 2) base_score += 20;
- System.out.println("What is 4 + 1 ?");
- ans = sc.nextInt();
- if(ans == 5) base_score += 20;
- System.out.println("What is 4 + 3 ?");
- ans = sc.nextInt();
- if(ans == 7) base_score += 20;
- }
- protected int get_score ()
- {
- return base_score;
- }
- protected int get_lev_score()
- {
- return base_score;
- }
- };
- class Intermediate extends Beginner
- {
- private int Inter_score;
- Intermediate(String name , int roll , int score)
- {
- super(name , roll , score);
- Inter_score = 0;
- }
- @Override
- protected void Questions()
- {
- Scanner sc = new Scanner(System.in);
- System.out.println("Hey :" + name + " Welcome to Intermediate level");
- System.out.println("What is 1 * 2 ?");
- ans = sc.nextInt();
- if(ans == 2) Inter_score += 20;
- System.out.println("What is 4 * 5 ?");
- ans = sc.nextInt();
- if(ans == 20) Inter_score += 20;
- System.out.println("What is 9 / 3 ?");
- ans = sc.nextInt();
- if(ans == 3) Inter_score += 20;
- System.out.println("What is 4 * 1 / 2 ?");
- ans = sc.nextInt();
- if(ans == 2) Inter_score += 20;
- System.out.println("What is 4 + 9 / 3 ?");
- ans = sc.nextInt();
- if(ans == 7) Inter_score += 20;
- }
- @Override
- protected int get_score ()
- {
- return (super.get_score() + Inter_score);
- }
- @Override
- protected int get_lev_score()
- {
- return Inter_score;
- }
- }
- class Advanced extends Intermediate
- {
- private int Adv_score;
- Advanced(String name ,int roll , int score)
- {
- super(name , roll , score);
- Adv_score = 0;
- }
- @Override
- protected void Questions()
- {
- Scanner sc = new Scanner(System.in);
- System.out.println("Hey :" + name + " Welcome to Advanced level");
- System.out.println("What is 7 mod 5 ?");
- ans = sc.nextInt();
- if(ans == (7 % 5)) Adv_score += 20;
- System.out.println("What is f'(0) if f(x) = x + sin(x) ?");
- ans = sc.nextInt();
- if(ans == 2) Adv_score += 20;
- System.out.println("What is the y value of minima of f(x) = x^2 + 1 ?");
- ans = sc.nextInt();
- if(ans == 1) Adv_score += 20;
- System.out.println("What is if f(x) = 3x^2 + 2x , F(5) = ? F(x) = integrated form of f(x) if C = 0");
- ans = sc.nextInt();
- if(ans == 150) Adv_score += 20;
- System.out.println("What is ((sin(45) * cosec(45)) + cosec(90) + tan(45) = ? arguments are in degrees ?");
- ans = sc.nextInt();
- if(ans == 3) Adv_score += 20;
- }
- protected int get_score()
- {
- return (super.get_score() + Adv_score);
- }
- protected int get_lev_score()
- {
- return (Adv_score);
- }
- }
- class ExamDriver
- {
- public static void main(String args[])
- {
- String name ; int Rollno;
- Scanner sc = new Scanner(System.in);
- System.out.println("Enter the Name of user: ");
- name = sc.nextLine();
- System.out.println("Enter the roll number of user");
- Rollno = sc.nextInt();
- Beginner ob_b = new Beginner( name , Rollno , 0);
- ob_b.Questions();
- System.out.println("Level Score: " + ob_b.get_lev_score() + "%");
- if(ob_b.get_lev_score() < 60)
- {
- System.out.println("You cannot progress further\n");
- return;
- }
- Intermediate ob_i = new Intermediate( name , Rollno , ob_b.get_score());
- ob_i.Questions();
- System.out.println("Level Score: " + ob_i.get_lev_score() + "%");
- if(ob_i.get_lev_score() < 60)
- {
- System.out.println("You cannot progress further\n");
- return;
- }
- Advanced ob_ad = new Advanced(name , Rollno , ob_i.get_score());
- ob_ad.Questions();
- System.out.println("Level Score: " + ob_ad.get_lev_score() + "%");
- System.out.println("Total Score is: " + ob_ad.get_score() / 3.0 + "%" );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement