×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Create A Program to Create a College Billing System Assignment Solution

July 06, 2024
Alice Grey
Alice Grey
🇦🇺 Australia
Java
Alice Grey is a seasoned Java Coding Specialist with 13 years of practice. He has a Master's degree from the University of Melbourne, Australia.
Key Topics
  • Instructions
  • Requirements and Specifications
Tip of the day
Use well-structured shaders to optimize rendering and ensure efficient resource management. Start with simple shapes, gradually adding complexity, and debug in small steps to identify errors easily.
News
An open-source framework that allows developers to create rich Python applications in the browser using HTML's interface, bridging the gap between web development and Python scripting.

Instructions

Objective

Write a java homework to create college billing system.

Requirements and Specifications

Advanced Java 100 points

Due date – Feb 25 11:59pm (nothing late- solution posted at midnight)

You are to create a program to calculate a College bill for a student. You will have two new user defined classes.

The first user defined class will have a default constructor that will assign the following data to variables to your choice. Therefore, the only this thing this class will do is to assign these values to variables:

  1. Cost of the tuition rate per credits = $750
  2. Cost of the technology fee =$50
  3. Cost of three levels of meal plans,
  • gold,=$3,500
  • silver=$3,000
  • bronze=$2,500
  • Cost of parking pass=$200
    1. The second userdefined class will contain the methods:
    2. a default constructor that has the first class above passed to itand data from the first class is assigned to variables of your choice in this second class

    A method that prompts the user for the following data:

    • student name
    • number of credits
    • room amount
    • which meal plan the student wants(gold, silver or bronze)

    A method to calculate the following:

    • cost of room and board= (cost of the meal plan + room amount) You will need an if statement to calculate the meal plan based on the meal plan costs passed in
    • tuition = number of credits * the tuition rate passed in
    • final technology fee = technology fee passed in * number of credits
    • final bill = room and board + final technology fee + parking pass (passed in) +tuition

    A method to print all of the following data in one dialog box using currency format (example of using currency formatting is included with this assignment)

    • student name
    • number of credits
    • tuition the student owes
    • room and board amount
    • parking pass amount
    • final technology fee
    • final bill due

    What to turn in:

    • Create a word document and first copy your code
    • Then copy a screen shot of the final output
    • Submit the word document to blackboard

    PLEASE NOTE: You text in the word document MUST be black. Submissions with light text will not be accepted.

    Source Code

    import javax.swing.*; import java.text.DecimalFormat; public class CollegeBill { private final double tuitionRatePerCredits; private final double technologyFee; private final double goldMealPlan; private final double silverMealPlan; private final double bronzeMealPlan; private final double parkingPass; private String studentName; private double numberOfCredits; private int roomAmount; private String mealPlan; private double roomAndBoard; private double tuition; private double finalTechnologyFee; private double finalBillDue; public CollegeBill(Price price) { this.tuitionRatePerCredits = price.getTuitionRatePerCredits(); this.technologyFee = price.getTechnologyFee(); this.goldMealPlan = price.getGoldMealPlan(); this.silverMealPlan = price.getSilverMealPlan(); this.bronzeMealPlan = price.getBronzeMealPlan(); this.parkingPass = price.getParkingPass(); } public void readUserInfo() { studentName = JOptionPane .showInputDialog(null,"Please, enter student name: ","College Bill Data", JOptionPane.QUESTION_MESSAGE) .trim(); while (true) { try { numberOfCredits = Double.parseDouble( JOptionPane.showInputDialog(null,"Please, enter number of credits: ","College Bill Data", JOptionPane.QUESTION_MESSAGE) .trim()); if (numberOfCredits <= 0.0) { throw new IllegalArgumentException(); } break; } catch (Exception e) { System.out.print("Invalid input"); } } while (true) { try { roomAmount = Integer.parseInt( JOptionPane .showInputDialog(null,"Please, enter room amount: ","College Bill Data", JOptionPane.QUESTION_MESSAGE) .trim()); if (roomAmount < 0) { throw new IllegalArgumentException(); } break; } catch (Exception e) { System.out.print("Invalid input"); } } while (true) { try { mealPlan = JOptionPane .showInputDialog(null,"Please, enter meal plan (gold/silver/bronze): ","College Bill Data", JOptionPane.QUESTION_MESSAGE) .trim() .toLowerCase(); if (!"gold".equals(mealPlan) && !"silver".equals(mealPlan) && !"bronze".equals(mealPlan)) { throw new IllegalArgumentException(); } break; } catch (Exception e) { System.out.print("Invalid input"); } } } public void calculate() { double meanPlanCost = bronzeMealPlan; if ("gold".equals(mealPlan)) { meanPlanCost = goldMealPlan; } else if ("silver".equals(mealPlan)) { meanPlanCost = silverMealPlan; } roomAndBoard = meanPlanCost + roomAmount; tuition = tuitionRatePerCredits * numberOfCredits; finalTechnologyFee = technologyFee * numberOfCredits; finalBillDue = roomAndBoard + finalTechnologyFee + parkingPass + tuition; } public void printInfo() { StringBuilder builder = new StringBuilder(); DecimalFormat df = new DecimalFormat("$##,###.##"); builder.append(String.format("%-20s", "Student Name:")).append(studentName) .append(System.lineSeparator()); builder.append(String.format("%-20s", "Number of credits:")).append(df.format(numberOfCredits)) .append(System.lineSeparator()); builder.append(String.format("%-20s", "Tuition:")).append(df.format(tuition)) .append(System.lineSeparator()); builder.append(String.format("%-20s", "Room and board:")).append(df.format(roomAndBoard)) .append(System.lineSeparator()); builder.append(String.format("%-20s", "Parking pass:")).append(df.format(parkingPass)) .append(System.lineSeparator()); builder.append(String.format("%-20s", "Technology fee:")).append(df.format(finalTechnologyFee)) .append(System.lineSeparator()); builder.append(String.format("%-20s", "Bill due:")).append(df.format(finalBillDue)) .append(System.lineSeparator()); JOptionPane.showMessageDialog(null, builder.toString(), "College Bill", JOptionPane.INFORMATION_MESSAGE); } public static void main(String[] args) { Price price = new Price(); CollegeBill collegeBill = new CollegeBill(price); collegeBill.readUserInfo(); collegeBill.calculate(); collegeBill.printInfo(); } } PRICE public class Price { private final double tuitionRatePerCredits; private final double technologyFee; private final double goldMealPlan; private final double silverMealPlan; private final double bronzeMealPlan; private final double parkingPass; public Price() { this.tuitionRatePerCredits = 750; this.technologyFee = 50; this.goldMealPlan = 3500; this.silverMealPlan = 3000; this.bronzeMealPlan = 2500; this.parkingPass = 200; } public double getTuitionRatePerCredits() { return tuitionRatePerCredits; } public double getTechnologyFee() { return technologyFee; } public double getGoldMealPlan() { return goldMealPlan; } public double getSilverMealPlan() { return silverMealPlan; } public double getBronzeMealPlan() { return bronzeMealPlan; } public double getParkingPass() { return parkingPass; } }

    Related Samples

    Explore our Java assignment samples to gain clarity and insights. These examples showcase a variety of Java programming concepts, from basic syntax to advanced algorithms, helping you understand and apply key principles effectively. Enhance your learning experience and improve your coding skills with our comprehensive Java examples.