+1 678 648 4277 
Table Of Contents
  • A Generic Program That Computes Total College Costs Per Semester
  • User Input
  • Expected Output
  • Java Code Solution

A Generic Program That Computes Total College Costs Per Semester

A certain college tuition rate is $300 per credit. Using the following tables data, write a generic program to compute the total college costs per semester.
Total Credits Taken Per Semester Discount
0-10 0%
11-15 8%
16-25 12%
Registration categories Registration Fee
Early $50.00
On time $75.00
Late $100.00

User Input

For early registration, type 1, for registration on time, type 2, for late registration, type 3 2
Enter the total credits student is taking 12

Expected Output

Registration fee $75.00
Tuition cost $3,312.00
Total $3,387.00

Java Code Solution

package marv.project7;
importjava.text.DecimalFormat;
importjava.util.Scanner;
public class Registration {
    // Entry point of the program
public static void main(String[] args) {
final double TUITION_RATE_PER_CREDIT = 300;
intregistrationType;
intnumCredits;
doubleregistrationFee, discountRate;
doubletuitionCost, totalCost;
doublediscountAmount;
DecimalFormatdecimalFormat = new DecimalFormat("#,###.00");
        Scanner kb = new Scanner(System.in);
System.out.println("For early registration, type 1\n"
                + "For registration on time, type 2\n"
                + "For late registration, type 3");
registrationType = kb.nextInt();
switch (registrationType) {
case 1:
registrationFee = 50;
break;
case 2:
registrationFee = 75;
break;
case 3:
registrationFee = 100;
break;
default:
registrationFee = 0;
        }
System.out.println("Enter the total credits student is taking");
numCredits = kb.nextInt();
if(numCredits>= 16) {
discountRate = 0.12;
        } else if(numCredits>= 11) {
discountRate = 0.08;
        } else {
discountRate = 0;
        }
tuitionCost = TUITION_RATE_PER_CREDIT * numCredits;
discountAmount = tuitionCost * discountRate;
totalCost = tuitionCost - discountAmount + registrationFee;
System.out.println("Registration fee\t$" + decimalFormat.format(registrationFee));
System.out.println("Tuition cost\t$" + decimalFormat.format(tuitionCost - discountAmount));
System.out.println("Total\t$" + decimalFormat.format(totalCost));
    }
}