Create a GUI application that calculates and displays the total travel expenses
ID: 3833433 • Letter: C
Question
Create a GUI application that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: Number of days on the trip Amount of airfare, if any Amount of car rental fees, if any Number of miles driven, if a private vehicle was used Amount of parking fees, if any Amount of taxi charges, if any Conference or seminar registration fees, if any Lodging charges, per night The company reimburses travel expenses according to the following policy: $37 per day for meals Parking fees, up to $10.00 per day Taxi charges up to $20.00 per day Lodging charges up to $95.00 per day If a private vehicle is used, $0.27 per mile driven The application should calculate and display the following: Total expenses incurred by the businessperson The total allowable expenses for the trip The excess that must be paid by the businessperson, if any The amount saved by the businessperson if the expenses were under the total allowed Theater Revenue A movie theater only keeps a percentage of the revenue earned from ticket sales. The the movie company. Create a GUI application that allows the user toExplanation / Answer
public class TravelExpenses extends JFrame
{
//Declare components
// A panel to hold labels and text fields
// A panel for the buttons
// Label prompting for number of days
// Label prompting for airfare
// Label prompting for car rental
// Label prompting for miles driven
// Label prompting for parking fees
// Label prompting for taxi charges
// Label prompting for conf. registration
// Label prompting for per-night lodging
// Textfield for Number of days
// Textfield for Airfare
// Textfield for Car rental
// Textfield for Miles driven
// Textfield for Parking fees
// Textfield for Taxi charges
// Textfield for Conference registration
// Textfield for Per-night lodging
//Button to Calculates everything
// Button to Resets everything
// Declare the 5 required Constants
//Constructor
public TravelExpenses()
{
// Set the title.
// Specify what happens when the close button is clicked.
// Build the panel that contains the labels and text fields.
// Build the panel that contains the buttons.
// Add the panels to the content pane.
// Pack and display the window.
}
//buildPanel method
private void buildPanel()
{
// Create the 8 labels prompting for the required data.
// Create the 8 text fields for the required data.
// Create a panel.
// Add a layout manager use GridLayout(10,2).
// Add the 8 labels, 8 text fields to the panel.
// Put an empty border around the panel (10, 10, 1, 10).
}
//buildButtonPanel method
private void buildButtonPanel()
{
// Create a button to calculate the expenses & reimbursement.
// Add an action listener to the button.
// Create a button to reset everything.
// Add an action listener to the button.
// Put the buttons in their own panel.
}
//CalcButtonListener is an action listener class for the calcbutton component.
private class CalcButtonListener implements ActionListener
{
//Declare variables for days, air, car rental, miles, meals parking, etc.
// actionPerformed method
public void actionPerformed(ActionEvent e)
{
// Declare variables for Actual expenses incurred, Reimbursable expenses
Amount saved, Excess amount spent, Output message
// Create a DecimalFormat object to format output.
// Get the data entered.
// Determine the actual expenses.
// Determine the reimbursement amounts.
// Display the results.
}
// getData method-gets the data entered by the user.
private void getData()
{
EXAMPLES : days = Integer.parseInt(numDays.getText());
air = Double.parseDouble(airfare.getText());
// There are 6 more to code
}
//Determine Actual Expenses method
private double determineActualExpenses()
{
// calculate actual expense total here and return as a double
}
//Determine Reimbursement method
private double determineReimbursement()
{
// Calculate meal reimbursement.
// Determine parking fee reimbursement.
// Determine taxi charge reimbursement.
// Determine lodging reimbursement.
// return reimbursable as a double
}
} // end of inner class
// ResetButtonListener is an action listener class for the resetButton component.
private class ResetButtonListener implements ActionListener
{
//actionPerformed method
public void actionPerformed(ActionEvent e)
{
//Set each textfield to zero
}
} // End of inner class
// The main method creates an instance of the TravelExpenses class.
public static void main(String[] args)
{
TravelExpenses te = new TravelExpenses();
}
}