JHJiban

Lab 03

Aug 13th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CourseFee {
  4.  
  5.     public int n;
  6.     public double total, ssc, hsc, fee;
  7.     Scanner input = new Scanner(System.in);
  8.     public void calculate(double fee, double hsc, double ssc)
  9.     {
  10.         this.hsc=ssc;
  11.         this.ssc=hsc;
  12.         this.fee=fee;
  13.         if(hsc<=4.79 && ssc==5)
  14.         {
  15.             total = fee;
  16.         }
  17.         else if(hsc==5 && ssc==5)
  18.         {
  19.             System.out.println("Press 1: Golden GPA 5\nPress 2: General GPA 5");
  20.             n=input.nextInt();
  21.             if(n==1)
  22.             {
  23.                 total = fee;
  24.                 fee -= total;
  25.             }
  26.             else
  27.             {
  28.                 total = fee * 0.5;
  29.                 fee -= total;
  30.             }
  31.  
  32.         }
  33.         else if(hsc==5)
  34.         {
  35.             System.out.println("Press 1: Golden GPA 5\nPress 2: General GPA 5");
  36.             n=input.nextInt();
  37.             if(n==1)
  38.             {
  39.                 total = fee * 0.75;
  40.                 fee -= total;
  41.             }
  42.             else
  43.             {
  44.                 total = fee * 0.3;
  45.                 fee -= total;
  46.             }
  47.         }
  48.         else if(hsc>=4.90 && hsc<=4.99)
  49.         {
  50.             total = fee * 0.2;
  51.             fee -= total;
  52.         }
  53.         else if(hsc>=4.80 && hsc<=4.89)
  54.         {
  55.             total = fee * 0.1;
  56.             fee -= total;
  57.         }
  58.          System.out.println("Course Fee Based On Result: " + fee);
  59.     }
  60.  
  61.     public static void main(String[] args) {
  62.         CourseFee c=new CourseFee();
  63.         Scanner input = new Scanner(System.in);
  64.         System.out.println("Your HSC GPA: ");
  65.         c.hsc=input.nextDouble();
  66.         System.out.println("Your SSC GPA: ");
  67.         c.ssc=input.nextDouble();
  68.         System.out.println("Total Semester Course Fee: ");
  69.         c.fee=input.nextDouble();
  70.         c.calculate(c.fee, c.ssc, c.hsc);
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment