Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package kobbii;
- import java.util.Scanner;
- public class tuitionClass {
- public static void main(String[] args)
- {
- tuitionClass fee = new tuitionClass();
- fee.runTuition();
- }
- public void runTuition()
- {
- int userInput;
- int totalAmmountDue, payment;
- Scanner scanner = new Scanner(System.in);
- tuitionClass fee = new tuitionClass();
- System.out.print("Enter Total Ammount Due: ");
- totalAmmountDue = scanner.nextInt();
- scanner.nextLine();
- while(true)
- {
- System.out.println("Choose:\n [1] Scholar\n [2] Non Scholar\n [ANY] Exit");
- System.out.print("Enter: ");
- userInput = scanner.nextInt();
- if(userInput == 1)
- {
- fee.scholar(totalAmmountDue);
- }
- else if(userInput == 2)
- {
- fee.nonScholar(totalAmmountDue);
- }
- else {
- System.exit(0);
- }
- }
- }
- public void nonScholar(int amountDue) {
- int userInput;
- Scanner scanner = new Scanner(System.in);
- tuitionClass fee = new tuitionClass();
- while (true) {
- System.out.println("Choose:\n [1] Cash\n [2] Installment\n [ANY] Exit");
- System.out.print("Enter: ");
- userInput = scanner.nextInt();
- if (userInput == 1) { // 10% discount for cash payment
- double discountedAmount = amountDue * 0.1;
- int totalAmount = amountDue - (int) discountedAmount;
- System.out.println("Total amount due after 10% discount for cash payment: " + totalAmount);
- System.out.println();
- } else if (userInput == 2) { // 10% interest for installment
- double interestAmount = amountDue * 0.1;
- int totalAmount = amountDue + (int) interestAmount;
- System.out.println("Total amount due after 10% interest for installment: " + totalAmount);
- System.out.println();
- } else {
- break;
- }
- }
- }
- public void scholar(int amountDue) {
- int userInput;
- Scanner scanner = new Scanner(System.in);
- tuitionClass fee = new tuitionClass();
- while (true) {
- System.out.println("Choose:\n [1] Full Scholar\n [2] Half Scholar\n [ANY] Exit");
- System.out.print("Enter: ");
- userInput = scanner.nextInt();
- if (userInput == 1) { // 90% discount for full scholar
- double discountedAmount = amountDue * 0.9;
- int totalAmount = (int) discountedAmount;
- System.out.println("Total amount due after 90% discount for full scholar: " + totalAmount);
- System.out.println();
- } else if (userInput == 2) { // 50% discount for half scholar
- double discountedAmount = amountDue * 0.5;
- int totalAmount = (int) discountedAmount;
- System.out.println("Total amount due after 50% discount for half scholar: " + totalAmount);
- System.out.println();
- } else {
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement