Advertisement
anik314159

Untitled

Jun 22nd, 2022 (edited)
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.91 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Beginner
  4. {
  5.     static protected String name;
  6.     static protected int roll;
  7.     protected int ans;
  8.     private int base_score;
  9.     Beginner(String name, int rollNo , int score)
  10.     {
  11.         this.name = name;
  12.         this.roll = rollNo;
  13.         ans = 0;
  14.         base_score = score;
  15.     }
  16.  
  17.     protected void Questions()
  18.     {  
  19.         Scanner sc = new Scanner(System.in);
  20.         System.out.println("Hi " + name +" Welcome to Beginner Level");
  21.         System.out.println("What is 1 + 2 ?");
  22.         ans = sc.nextInt();
  23.         if(ans == 3) base_score += 20;
  24.  
  25.         System.out.println("What is 4 + 5 ?");
  26.         ans = sc.nextInt();
  27.         if(ans == 9) base_score += 20;
  28.  
  29.         System.out.println("What is 1 + 1 ?");
  30.         ans = sc.nextInt();
  31.         if(ans == 2) base_score += 20;
  32.  
  33.         System.out.println("What is 4 + 1 ?");
  34.         ans = sc.nextInt();
  35.         if(ans == 5) base_score += 20;
  36.  
  37.         System.out.println("What is 4 + 3 ?");
  38.         ans = sc.nextInt();
  39.         if(ans == 7) base_score += 20;
  40.     }
  41.  
  42.     protected int get_score ()
  43.     {
  44.         return base_score;
  45.     }
  46.  
  47.     protected int get_lev_score()
  48.     {
  49.         return base_score;
  50.     }
  51. };
  52.  
  53. class Intermediate extends Beginner
  54. {
  55.     private int Inter_score;
  56.     Intermediate(String name , int roll , int score)
  57.     {  
  58.         super(name , roll , score);
  59.         Inter_score = 0;
  60.     }
  61.  
  62.     @Override
  63.     protected void Questions()
  64.     {
  65.         Scanner sc = new Scanner(System.in);
  66.         System.out.println("Hey :" + name + " Welcome to Intermediate level");
  67.         System.out.println("What is 1 * 2 ?");
  68.         ans = sc.nextInt();
  69.         if(ans == 2) Inter_score += 20;
  70.  
  71.         System.out.println("What is 4 * 5 ?");
  72.         ans = sc.nextInt();
  73.         if(ans == 20) Inter_score += 20;
  74.  
  75.         System.out.println("What is 9 / 3 ?");
  76.         ans = sc.nextInt();
  77.         if(ans == 3) Inter_score += 20;
  78.  
  79.         System.out.println("What is 4 * 1 / 2 ?");
  80.         ans = sc.nextInt();
  81.         if(ans == 2) Inter_score += 20;
  82.  
  83.         System.out.println("What is 4 + 9 / 3  ?");
  84.         ans = sc.nextInt();
  85.         if(ans == 7) Inter_score += 20;
  86.  
  87.     }
  88.  
  89.     @Override
  90.     protected int get_score ()
  91.     {        
  92.         return (super.get_score() + Inter_score);
  93.     }
  94.     @Override
  95.     protected int get_lev_score()
  96.     {
  97.         return Inter_score;
  98.     }
  99.  
  100. }
  101. class Advanced extends Intermediate
  102. {
  103.     private int Adv_score;
  104.     Advanced(String name ,int roll , int score)
  105.     {  
  106.         super(name , roll , score);
  107.         Adv_score = 0;
  108.     }
  109.  
  110.     @Override
  111.     protected void Questions()
  112.     {
  113.         Scanner sc = new Scanner(System.in);
  114.         System.out.println("Hey :" + name + " Welcome to Advanced level");
  115.         System.out.println("What is 7 mod 5 ?");
  116.         ans = sc.nextInt();
  117.         if(ans == (7 % 5)) Adv_score += 20;
  118.  
  119.         System.out.println("What is f'(0) if f(x) = x + sin(x) ?");
  120.         ans = sc.nextInt();
  121.         if(ans == 2) Adv_score += 20;
  122.  
  123.         System.out.println("What is the y value of minima of f(x) = x^2 + 1 ?");
  124.         ans = sc.nextInt();
  125.         if(ans == 1) Adv_score += 20;
  126.  
  127.         System.out.println("What is if f(x) = 3x^2 + 2x , F(5) = ? F(x) = integrated form of f(x) if C = 0");
  128.         ans = sc.nextInt();
  129.         if(ans == 150) Adv_score += 20;
  130.  
  131.         System.out.println("What is ((sin(45) * cosec(45)) + cosec(90) + tan(45) = ? arguments are in degrees ?");
  132.         ans = sc.nextInt();
  133.         if(ans == 3) Adv_score += 20;
  134.  
  135.     }
  136.  
  137.    
  138.     protected int get_score()
  139.     {
  140.         return (super.get_score() + Adv_score);
  141.     }
  142.     protected int get_lev_score()
  143.     {
  144.         return (Adv_score);
  145.     }
  146.  
  147.    
  148.  
  149. }
  150.  
  151. class ExamDriver
  152. {
  153.     public static void main(String args[])
  154.     {
  155.         String name ; int Rollno;
  156.         Scanner sc = new Scanner(System.in);
  157.         System.out.println("Enter the Name of user: ");
  158.         name = sc.nextLine();
  159.         System.out.println("Enter the roll number of user");
  160.         Rollno = sc.nextInt();
  161.         Beginner ob_b = new Beginner( name , Rollno , 0);
  162.         ob_b.Questions();
  163.         System.out.println("Level Score: " + ob_b.get_lev_score() + "%");
  164.         if(ob_b.get_lev_score() < 60)
  165.         {
  166.             System.out.println("You cannot progress further\n");
  167.             return;
  168.         }
  169.  
  170.         Intermediate ob_i = new Intermediate( name , Rollno , ob_b.get_score());
  171.         ob_i.Questions();
  172.         System.out.println("Level Score: " + ob_i.get_lev_score() + "%");
  173.         if(ob_i.get_lev_score() < 60)
  174.         {
  175.             System.out.println("You cannot progress further\n");
  176.             return;
  177.         }
  178.         Advanced ob_ad = new Advanced(name , Rollno , ob_i.get_score());
  179.         ob_ad.Questions();
  180.  
  181.         System.out.println("Level Score: " + ob_ad.get_lev_score() + "%");
  182.         System.out.println("Total Score is: " + ob_ad.get_score() / 3.0 + "%" );
  183.  
  184.     }
  185. }
  186.  
  187.  
  188.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement