Advertisement
JHJiban

Lab Session 03

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