Question

In: Computer Science

Design and implement a Java program to create a GUI application that for calculating an employee’s...

Design and implement a Java program to create a GUI application that for calculating an employee’s travel expenses and reimbursement. The user will enter the following data:

∙ Number of days on the trip

∙ Amount of the airfare, if any

∙ Amount of car rental fees, if any

∙ Number of miles driven, if a private vehicle is used

∙ Amount of parking fees, if any

∙ Amount of taxi charges, if any

∙ Conference or seminar registration fees, if any

∙ Lodging charges, per night

Once all expanses are entered the program should then calculate what the employee’s reimbursement will be based on the following guidelines:

∙ $17 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

Once calculated your program should display the following information:

∙ Total expenses incurred by the business person

∙ The total allowable expenses for the trip

∙ The excess that must be paid by the business person, if any

∙ The amount saved by the business person if the expenses are under the total allowed

The layout and formatting of your GUI interface should be creative, attractive and easy to use.

Solutions

Expert Solution

Source Code:


package travelexpenses;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class TravExp extends JFrame
{
private JPanel traInfoPan;
private JPanel butPan;
private JLabel daysLabel;
private JLabel airfairLabel;
private JLabel carRentLabel;
private JLabel milesLabel;
private JLabel parkingLabel;
private JLabel taxiLabel;
private JLabel confLabel;
private JLabel lodgeLabel;
private JTextField daysTextField;
private JTextField airfairTextField;
private JTextField carRentTextField;
private JTextField milTextField;
private JTextField paTextField;
private JTextField txTextField;
private JTextField confTextField;
private JTextField lodgeTextField;
private JButton reset_Button;
private JButton calculate_Button;
private double mealAmt = 37.00;
private double parkfeesReimb = 10.00;
private double taxichargeReimb = 20.00;
private double lodgchargeReimb = 95.00;
private double privVehReimb = 0.27;
public TravExp( )
{
super("TRAVEL EXPENSES");
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
build_Trav_Info();
build_But_Pan();
add(traInfoPan, BorderLayout.CENTER);
add(butPan, BorderLayout.SOUTH);
pack();
setVisible(true);
}
private void build_Trav_Info()
{
daysLabel = new JLabel("Number of days on trip: ");
airfairLabel = new JLabel("Amount of airfair: ");
carRentLabel = new JLabel("Amount of car rental fees: ");
milesLabel = new JLabel("Number of Miles driven: ");
parkingLabel = new JLabel("Amount of Parking fees: ");
taxiLabel = new JLabel("Amount of Taxi charges: ");
confLabel = new JLabel("Conference or Seminar registration fees: ");
lodgeLabel = new JLabel("Lodging charges per night: ");
daysTextField = new JTextField(3);
airfairTextField = new JTextField(8);
carRentTextField = new JTextField(8);
milTextField = new JTextField(4);
paTextField = new JTextField(6);
txTextField = new JTextField(6);
confTextField = new JTextField(8);
lodgeTextField = new JTextField(6);
traInfoPan = new JPanel();
traInfoPan.setLayout(new GridLayout(10, 2));
traInfoPan.add(daysLabel);
traInfoPan.add(daysTextField);
traInfoPan.add(airfairLabel);
traInfoPan.add(airfairTextField);
traInfoPan.add(carRentLabel);
traInfoPan.add(carRentTextField);
traInfoPan.add(milesLabel);
traInfoPan.add(milTextField);
traInfoPan.add(parkingLabel);
traInfoPan.add(paTextField);
traInfoPan.add(taxiLabel);
traInfoPan.add(txTextField);
traInfoPan.add(confLabel);
traInfoPan.add(confTextField);
traInfoPan.add(lodgeLabel);
traInfoPan.add(lodgeTextField);
traInfoPan.setBorder(BorderFactory.createEmptyBorder(10, 10, 1, 10));
}
  
private void build_But_Pan()
{
calculate_Button = new JButton("CALCULATE");
calculate_Button.addActionListener(new calculate_ButtonListener());
reset_Button = new JButton("RESET");
butPan = new JPanel();
butPan.setLayout(new BorderLayout(5, 5));
butPan.add(reset_Button, BorderLayout.WEST);
butPan.add(calculate_Button, BorderLayout.CENTER);
butPan.setBorder(BorderFactory.createEmptyBorder(1, 10, 10, 10));
}
private class calculate_ButtonListener implements ActionListener
{
String inp;
int dy;
double ar;
double carrent;
double mls;
double park;
double tx;
double conf;
double lodg;
double mealAmt;
public void actionPerformed(ActionEvent e)
{
double actExp;
double milesExp;
double allowExp;
double exAir;
double exCarRen;
double exCarPark;
double exTaxi;
double exLodg;
double exAmtTot;
double amtSav=0;
double paidBackAmt=0;
DecimalFormat dol = new DecimalFormat("$#,##0.00");
dy = Integer.parseInt(daysTextField.getText());
ar = Double.parseDouble(airfairTextField.getText());
carrent = Double.parseDouble(carRentTextField.getText());
mls = Double.parseDouble(milTextField.getText());
park = Double.parseDouble(paTextField.getText());
tx = Double.parseDouble(txTextField.getText());
conf = Double.parseDouble(confTextField.getText());
lodg = Double.parseDouble(lodgeTextField.getText());
milesExp = mls * privVehReimb;
actExp = (carrent + park + tx + lodg +mealAmt)
*dy+ar+milesExp+ conf ;
allowExp=(mealAmt+parkfeesReimb+taxichargeReimb+lodgchargeReimb)*dy+milesExp+ar+conf;
if(actExp>allowExp)
paidBackAmt=actExp-allowExp;
else
amtSav=allowExp-actExp;
if(paidBackAmt>0)
JOptionPane.showMessageDialog(null, "Total expenses: "
+ dol.format(actExp) +"\n" +"Total allowable expenses: "
+ dol.format(allowExp)+"\n" +"\n" + "Amount to be paid back: "
+dol.format(paidBackAmt));
else if(amtSav>0)
JOptionPane.showMessageDialog(null, "Total expenses: " + dol.format(actExp)
+"\n" +" Total allowable expenses: " + dol.format(allowExp)+"\n" +
"\n" + "Amount Saved: "+dol.format(amtSav));
else
JOptionPane.showMessageDialog(null, "Total expenses: " + dol.format(actExp)
+"\n" +"Allowable expenses: " + dol.format(allowExp)+"\n" );
}
}
private class reset_ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
daysTextField.setText("");
airfairTextField.setText("");
carRentTextField.setText("");
milTextField.setText("");
paTextField.setText("");
txTextField.setText("");
confTextField.setText("");
lodgeTextField.setText("");
}
}

public static void main(String[] args)
{
new TravExp();
}
}


Related Solutions

Design and implement a Java program that creates a GUI that will allow a customer to...
Design and implement a Java program that creates a GUI that will allow a customer to order pizza and other items from a Pizza Paarlor. The customer should be able to order a variety of items which are listed below. The GUI should allow the customer (viaJavaFX UI Controls - text areas, buttons, checkbox, radio button, etc.) to input the following information: Name of the customer First Name Last Name Phone number of the customer Type of food being order...
Create in java an interactive GUI application program that will prompt the user to use one...
Create in java an interactive GUI application program that will prompt the user to use one of three calculators, label project name MEDCALC. You can use any color you want for your background other than grey. Be sure to label main java box with “MEDCALC” and include text of “For use only by students” On all three calculators create an alert and signature area for each user. The alert should be something like “All calculations must be confirmed by user...
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...
***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...
You will design and create your own GUI application for the Bank project. This project should...
You will design and create your own GUI application for the Bank project. This project should be designed and written by Java programming. The requirements of the program: 1. The program will be best implemented as a multi-file program for each class. 2. The parameters and return types of each function and class member should be decided in advance. You may need to add more member variables and functions to the classes than those listed below. Also, you can throws...
Java - Design and implement an application that creates a histogram that allows you to visually...
Java - Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values. The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered. Sample...
By using javaFX as the GUI, design and implement java based algorithms using appropriate data structures...
By using javaFX as the GUI, design and implement java based algorithms using appropriate data structures for the following problem: Use depth-first search to find paths to all the vertices in a graph that are connected to a given start vertex s. A sample input file containing the number of vertices, number of edges and a list of edges called tinyCG.txt is provided for you to test your program.
Use the below info to create a java program A GUI interface to ensure a user...
Use the below info to create a java program A GUI interface to ensure a user is old enough to play a game. Properly formatted prompts to input name, address, phone number, and age. Remember that name, address, phone number, etc. can be broken out in additional fields. Refer to the tutorial from this week’s Reading Assignment Multiple vs. Single Field Capture for Phone Number Form Input for help with this. Instructions to ensure that the information is displayed back...
Write a program in Java Design and implement simple matrix manipulation techniques program in java. Project...
Write a program in Java Design and implement simple matrix manipulation techniques program in java. Project Details: Your program should use 2D arrays to implement simple matrix operations. Your program should do the following: • Read the number of rows and columns of a matrix M1 from the user. Use an input validation loop to make sure the values are greater than 0. • Read the elements of M1 in row major order • Print M1 to the console; make...
programing language JAVA: Design and implement an application that reads a sentence from the user, then...
programing language JAVA: Design and implement an application that reads a sentence from the user, then counts all the vowels(a, e, i, o, u) in the entire sentence, and prints the number of vowels in the sentence. vowels may be upercase
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT