Question

In: Computer Science

Create a GUI application in C# that calculates and displays the total travel expenses of a...

Create a GUI application in C# 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

Solutions

Expert Solution

Here is the code and please let me know if any errors occurs.

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.JOptionPane;

import java.text.DecimalFormat;

public class TravelExpenses extends JFrame

013

{

private JPanel travelInfoPanel;

private JPanel buttonPanel;

private JLabel numDaysOnTripLabel;

private JLabel amountAirfairLabel;

private JLabel amountCarRentalLabel;

private JLabel milesDrivenLabel;

private JLabel parkingFeesLabel;

private JLabel taxiFeesLabel;

private JLabel confRegLabel;

private JLabel lodgingChargesPerNightLabel;

private JTextField numDaysOnTripTextField;

private JTextField amountAirfairTextField;

private JTextField amountCarRentalTextField;

private JTextField milesDrivenTextField;

private JTextField parkingFeesTextField;

private JTextField taxiFeesTextField;

private JTextField confRegTextField;

private JTextField lodgingChargesPerNightTextField;

private JButton resetButton;

private JButton calcButton;

private double mealsAmount = 37.00;

private double parkingFeesReimbursed = 10.00;

private double taxiChargesReimbursed = 20.00;

private double lodgingChargesReimbursed = 95.00;

private double prVechiclePerMileReimbursed = 0.27;

public TravelExpenses()

{

super("Travel Expenses");

setLocationRelativeTo(null);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setLayout(new BorderLayout());

buildTravelInfoPanel();

buildButtonPanel();

add(travelInfoPanel, BorderLayout.CENTER);

add(buttonPanel, BorderLayout.SOUTH);

pack();

080

setVisible(true);

081

}

private void buildTravelInfoPanel()

{

numDaysOnTripLabel = new JLabel("Number of days on trip: ");

amountAirfairLabel = new JLabel("Amount of airfair: ");

amountCarRentalLabel = new JLabel("Amount of car rental: ");

milesDrivenLabel = new JLabel("Miles driven: ");

parkingFeesLabel = new JLabel("Parking Fees: ");

taxiFeesLabel = new JLabel("Taxi fees: ");

confRegLabel = new JLabel("Conference registration: ");

lodgingChargesPerNightLabel = new JLabel("Lodging charges per night: ");

numDaysOnTripTextField = new JTextField(3);

amountAirfairTextField = new JTextField(8);

amountCarRentalTextField = new JTextField(8);

milesDrivenTextField = new JTextField(4);

parkingFeesTextField = new JTextField(6);

taxiFeesTextField = new JTextField(6);

confRegTextField = new JTextField(8);

lodgingChargesPerNightTextField = new JTextField(6);

travelInfoPanel = new JPanel();

travelInfoPanel.setLayout(new GridLayout(10, 2));

travelInfoPanel.add(numDaysOnTripLabel);

travelInfoPanel.add(numDaysOnTripTextField);

travelInfoPanel.add(amountAirfairLabel);

travelInfoPanel.add(amountAirfairTextField);

travelInfoPanel.add(amountCarRentalLabel);

travelInfoPanel.add(amountCarRentalTextField);

travelInfoPanel.add(milesDrivenLabel);

travelInfoPanel.add(milesDrivenTextField);

travelInfoPanel.add(parkingFeesLabel);

travelInfoPanel.add(parkingFeesTextField);

travelInfoPanel.add(taxiFeesLabel);

travelInfoPanel.add(taxiFeesTextField);

travelInfoPanel.add(confRegLabel);

travelInfoPanel.add(confRegTextField);

travelInfoPanel.add(lodgingChargesPerNightLabel);

travelInfoPanel.add(lodgingChargesPerNightTextField);

travelInfoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 1, 10));

private void buildButtonPanel()

calcButton = new JButton("Calculate");

calcButton.addActionListener(new CalcButtonListener());

resetButton = new JButton("Reset");

buttonPanel = new JPanel();

buttonPanel.setLayout(new BorderLayout(5, 5));

buttonPanel.add(resetButton, BorderLayout.WEST);

buttonPanel.add(calcButton, BorderLayout.CENTER);

buttonPanel.setBorder(BorderFactory.createEmptyBorder(1, 10, 10, 10));

}

private class CalcButtonListener implements ActionListener

{

String input;

int days;

double air;

double carRental;

double miles;

double parking;

double taxi;

double confReg;

double lodging;

double mealsAmount;

public void actionPerformed(ActionEvent e)

{

double actualExpenses;

double milesExpenses;

double allowableExpenses;

double excessAir;

double excessCarRental;

double excessParking;

double excessTaxi;

double excessLodging;

double excessAmountTotal;

double amountSaved;

double paidBackAmount;

DecimalFormat dollar = new DecimalFormat("$#,##0.00");

}

private void getData()

{

days = Integer.parseInt(numDaysOnTripTextField.getText());

air = Double.parseDouble(amountAirfairTextField.getText());

carRental = Double.parseDouble(amountCarRentalTextField.getText());

miles = Double.parseDouble(milesDrivenTextField.getText());

parking = Double.parseDouble(parkingFeesTextField.getText());

taxi = Double.parseDouble(taxiFeesTextField.getText());

confReg = Double.parseDouble(confRegTextField.getText());

lodging = Double.parseDouble(lodgingChargesPerNightTextField.getText());

}

private void determineActualExpenses(double actualExpenses, double milesExpenses)

{

actualExpenses = air + carRental + parking + taxi + confReg + lodging;actualExpenses = actualExpenses + milesExpenses;

JOptionPane.showMessageDialog(null, "Total expenses: " + "\n" +"Allowable expenses: " + "\n" +"\n" + "Amount to be paid back: ");

}

private class ResetButtonListener implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

numDaysOnTripTextField.setText("");

amountAirfairTextField.setText("");

amountCarRentalTextField.setText("");

milesDrivenTextField.setText("");

parkingFeesTextField.setText("");

taxiFeesTextField.setText("");

confRegTextField.setText("");

lodgingChargesPerNightTextField.setText("");

}

}

}

public static void main(String[] args)

{

new TravelExpenses();

}

THANK YOU!! PLEASE VOTE


Related Solutions

In C# Create a GUI application that calculates and displays the total travel expenses of a...
In C# 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...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# 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...
C# A car dealer wants an application that calculates the cost of a car. The GUI...
C# A car dealer wants an application that calculates the cost of a car. The GUI application should link the “BuildYourCar.accdb” database and display all the data in four different “ListBox” based on the category. Each “ListBox” should display all the items in that category. The user can only choose one item from each “ListBox” to add an item to a car. As each item is selected, the application displays the item in a separate “ListBox” to display. If user...
Create an application that calculates and displays the amount of a homeowner’s property tax. The tax...
Create an application that calculates and displays the amount of a homeowner’s property tax. The tax is 1.35% of the property’s assessed value, which will be entered by the user. a. Prepare a Planning Chart for the application. b. Draw a sketch of an appropriate interface. Be sure to follow the GUI design guidelines covered in the chapter. The guidelines are summarized in Figure 2-20. (If you want to include an image in the interface, you can either use your...
Create an application that calculates and displays the starting and ending monthly balances for a checking...
Create an application that calculates and displays the starting and ending monthly balances for a checking account and a savings account. Welcome to the Account application Starting Balances Checking: $1,000.00 Savings: $1,000.00 Enter the transactions for the month Withdrawal or deposit? (w/d): w Checking or savings? (c/s): c Amount?: 500 Continue? (y/n): y Withdrawal or deposit? (w/d): d Checking or savings? (c/s): s Amount?: 200 Continue? (y/n): n Monthly Payments and Fees Checking fee: $1.00 Savings interest payment: $12.00 Final...
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays...
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays the cost of a customer’s yogurt purchase. Use a validation loop to prompt for and get from the user the number of yogurts purchased in the range 1-9. Then use a validation loop to prompt for and get from the user the coupon discount in the range 0-20%. Calculate the following:         ● Subtotal using a cost of $3.50 per yogurt.         ● Subtotal...
In C# Create a windows application which accepts the month number and displays the month name...
In C# Create a windows application which accepts the month number and displays the month name in a label.   Use a nested if... else statement to determine the month name. For months not in the range 1-12 display the message "Not a valid month"
Create a java Swing GUI application that presents the user with a “fortune”. Create a java...
Create a java Swing GUI application that presents the user with a “fortune”. Create a java Swing GUI application in a new Netbeans project called FortuneTeller. Your project will have a FortuneTellerFrame.java class (which inherits from JFrame) and a java main class: FortuneTellerViewer.java. Your application should have and use the following components: Top panel: A JLabel with text “Fortune Teller” (or something similar!) and an ImageIcon. Find an appropriate non-commercial Fortune Teller image for your ImageIcon. (The JLabel has a...
Create a C# Windows Console application that displays the following patterns separately, one after the other....
Create a C# Windows Console application that displays the following patterns separately, one after the other. You MUST use nested for loops to generate the patterns. All asterisks (*) should be displayed by a single statement of the form Console.Write("*"); which causes the asterisks to display side by side. A statement of the form Console.WriteLine(); can be used to move to the next line. A statement of the form Console.Write(" "); can be used to display a space for the...
C# Programming; Create a Windows Form Application that displays a scrollable list of 10 random integers...
C# Programming; Create a Windows Form Application that displays a scrollable list of 10 random integers in the range of 1 to 100. The form should also have (1) an Add button (and input textbox) for the user to add a new number to the list, (2) a Delete button to delete the current selected integer, (3) a Sort button to sort the list, (4) a Reverse button to display the list in reverse order, and (5) Display Multiple (and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT