Write a program that will compute and print the semester tuition bill for a stud
ID: 3631389 • Letter: W
Question
Write a program that will compute and print the semester tuition bill for a student.Example input would be:
First Name: Fred
Last Name: Jones
Address: 1934 Same Street
Phone Number: 703 334 5343
Credits Enrolled: 19
Qualifies for instate rate: yes
Late fee assessed: yes
On campus food: yes
Choose Food Plan: I-can't-stand-this-food
Health care option: yes
The calculations are as follows:
Tuition rates
Less than 12 credits: Instate=$102.50 outofstate=$351.00
12-18 credits: Instate=$75.45 outofstate=$255.00
Credits over 18: Instate=$93.00 outofstate=$304.00
Late fee is 10% of tuition bill figured on credit cost only
Incidental fees are $20/ credit up to a maximum of $250.00
Optional health care:
$25.00 first 10 credits
$20.00 next 5 credits
$15.00 over 15 credits
If on campus food is the case then further input from the user is necessary:
Meal plan stuff-your-face is $4,999.00
Meal plan I-can't-stand-this-food- is $3,499.00
Meal plan I'm-on-a-diet is $2,599.00
Example output for a single student
NAME Jim Jackson
ADDRESS 1934 Same Street
PHONE 703 334 5343
CREDITS 19
TUITION $1748.65
LATE FEE $174.86
INCIDENTAL $250.00
HEALTH CARE $410.00
MEAL PLAN $3,499.00
TOTAL $6082.51
Explanation / Answer
//Please rate me for my hard work. This thing takes a lot of time to type.
import java.util.Scanner;
public class tuitionBill {
public static String fname;
public static String lname;
public static String address;
public static String phone;
public static int credits;
public static double tuition;
public static double lateFee = 0;
public static double incidental;
public static double healthCare = 0; //default for no health care
public static double meal = 0; //default off campus
public static double total;
public double calculateTuition(){
return 1.0;
}
public static void main(String[] args){
String s;
Scanner input = new Scanner(System.in);
System.out.print("First Name: ");
fname = input.nextLine();
System.out.print("Last Name: ");
lname = input.nextLine();
System.out.print("Address: ");
address = input.nextLine();
System.out.print("Phone Number: ");
phone = input.nextLine();
System.out.print("Credits enrolled: ");
credits = input.nextInt();
if ((credits>0)&&(credits<=25)){
System.out.print("Qualifies for instate rate? (Type yes/no) ");
calculateTuition(input.next());
System.out.print("Late fee assessed? (Type yes/no) ");
if (input.next().toLowerCase().equals("yes"))
lateFee = tuition * 0.1;
System.out.print("On campus food? (Type yes/no) ");
if (input.next().toLowerCase().equals("yes")){
System.out.println("Choose a food plan.");
System.out.print("'a' (stuff-your-face), 'b' (I-can't-stand-this-food), other choices (I'm-on-a-diet): ");
s = input.next();
s.trim();
char aChar = s.charAt(0);
if ((aChar== 'a')||(aChar== 'A'))
meal = 4999;
else if ((aChar== 'b')||(aChar== 'C'))
meal = 3499;
else meal = 2599;
}//end on campus food if statement
System.out.print("Health care option? ");
if (input.next().toLowerCase().equals("yes")){
if (credits<=10) healthCare = 25*credits;
else if (credits<=15) healthCare = 250 + 20*(credits-10);
else healthCare = 350 + 15 * (credits-15);
}
incidental = 20 * credits;
if (incidental>=250) incidental = 250;
total = tuition + lateFee + incidental + healthCare + meal;
//--------- OUTPUT ----------
System.out.print(" NAME " + fname + " " + lname + " ");
System.out.print("ADDRESS " + address + " ");
System.out.print("PHONE " + phone + " ");
System.out.print("CREDITS " + credits + " ");
System.out.format("TUITION $%.2f%n", tuition);
System.out.format("LATE FEE $%.2f%n", lateFee);
System.out.format("INCIDENTAL $%.2f%n", incidental);
System.out.format("HEALTH CARE $%.2f%n", healthCare);
System.out.format("MEAL PLAN $%.2f%n", meal);
System.out.format("TOTAL $%.2f%n", total);
System.out.println(" End Process");
}//end credits in the (1,26) range if statement
else System.out.println("You need to have between 0 and 25 credits!");
}
public static void calculateTuition(String myString){
if (myString.toLowerCase().equals("yes")){
if (credits>18)
tuition = 93 * (credits - 18) + 75.45 * 6 + 102.50 * 12;
else if (credits>12) tuition = 102.5 * (credits - 12) + 102.50 * 12;
else tuition = 12 * credits;
}
else {
if (credits>18) tuition = 304 * (credits - 18) + 255 * 6 + 351 * 12;
else if (credits>12) tuition = 255 * (credits - 12) + 351 * 12;
else tuition = 351 * credits;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.