Advertisement
SenpaiZero

Untitled

Dec 6th, 2023
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.92 KB | None | 0 0
  1. package kobbii;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class tuitionClass {
  6.     public static void main(String[] args)
  7.     {
  8.  
  9.         tuitionClass fee = new tuitionClass();
  10.         fee.runTuition();
  11.     }
  12.    
  13.     public void runTuition()
  14.     {
  15.         int userInput;
  16.         int totalAmmountDue, payment;
  17.         Scanner scanner = new Scanner(System.in);
  18.         tuitionClass fee = new tuitionClass();
  19.  
  20.         System.out.print("Enter Total Ammount Due: ");
  21.         totalAmmountDue = scanner.nextInt();
  22.         scanner.nextLine();
  23.        
  24.         while(true)
  25.         {
  26.             System.out.println("Choose:\n [1] Scholar\n [2] Non Scholar\n [ANY] Exit");
  27.             System.out.print("Enter: ");
  28.             userInput = scanner.nextInt();
  29.             if(userInput == 1)
  30.             {
  31.                 fee.scholar(totalAmmountDue);
  32.             }
  33.             else if(userInput == 2)
  34.             {
  35.                 fee.nonScholar(totalAmmountDue);
  36.             }
  37.             else {
  38.                 System.exit(0);
  39.             }
  40.         }
  41.     }
  42.    
  43.     public void nonScholar(int amountDue) {
  44.         int userInput;
  45.         Scanner scanner = new Scanner(System.in);
  46.         tuitionClass fee = new tuitionClass();
  47.  
  48.         while (true) {
  49.             System.out.println("Choose:\n [1] Cash\n [2] Installment\n [ANY] Exit");
  50.             System.out.print("Enter: ");
  51.             userInput = scanner.nextInt();
  52.  
  53.             if (userInput == 1) { // 10% discount for cash payment
  54.                 double discountedAmount = amountDue * 0.1;
  55.                 int totalAmount = amountDue - (int) discountedAmount;
  56.                 System.out.println("Total amount due after 10% discount for cash payment: " + totalAmount);
  57.                 System.out.println();
  58.             } else if (userInput == 2) { // 10% interest for installment
  59.                 double interestAmount = amountDue * 0.1;
  60.                 int totalAmount = amountDue + (int) interestAmount;
  61.                 System.out.println("Total amount due after 10% interest for installment: " + totalAmount);
  62.                 System.out.println();
  63.             } else {
  64.                 break;
  65.             }
  66.         }
  67.     }
  68.  
  69.     public void scholar(int amountDue) {
  70.         int userInput;
  71.         Scanner scanner = new Scanner(System.in);
  72.         tuitionClass fee = new tuitionClass();
  73.  
  74.         while (true) {
  75.             System.out.println("Choose:\n [1] Full Scholar\n [2] Half Scholar\n [ANY] Exit");
  76.             System.out.print("Enter: ");
  77.             userInput = scanner.nextInt();
  78.  
  79.             if (userInput == 1) { // 90% discount for full scholar
  80.                 double discountedAmount = amountDue * 0.9;
  81.                 int totalAmount = (int) discountedAmount;
  82.                 System.out.println("Total amount due after 90% discount for full scholar: " + totalAmount);
  83.                 System.out.println();
  84.             } else if (userInput == 2) { // 50% discount for half scholar
  85.                 double discountedAmount = amountDue * 0.5;
  86.                 int totalAmount = (int) discountedAmount;
  87.                 System.out.println("Total amount due after 50% discount for half scholar: " + totalAmount);
  88.                 System.out.println();
  89.             } else {
  90.                 break;
  91.             }
  92.         }
  93.     }
  94.  
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement