Question

In: Computer Science

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 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

Note: Done accordingly. Please comment for any problem. Please Uprate. Thanks

Download solution:

https://drive.google.com/file/d/1f-hDbegoeClXzr7Kwit4gJee4TP3qTUH/view?usp=sharing

Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TravelExpenceCalculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void btnCalculate_Click(object sender, EventArgs e)
{
//declaring variables
int numberOfDays;
double amountOfAirfare = 0, amountOfCarRental = 0, numberOfMilesDriven = 0, amountOfParkingFees = 0, amountOfTaxiCharges = 0, conferenceFees = 0, lodgingCharges;
double totalExpense, totalReimbursement, extra=0, saved=0;
//checking if number of days are given
if (tbNumdays.Text.Equals(""))
{
MessageBox.Show("Please give number of days.");
}
//checking if lodging charges are given
else if (tbLodging.Text.Equals(""))
{
MessageBox.Show("Please give logding charges.");
}
else
{
try
{
//parsing input
numberOfDays = Int32.Parse(tbNumdays.Text);
amountOfCarRental=getValue(tbCarRental);
amountOfAirfare = getValue(tbAirfare);
numberOfMilesDriven = getValue(tbNumMiles);
amountOfParkingFees = getValue(tbParkingFees);
amountOfTaxiCharges = getValue(tbTaxiCharges);
conferenceFees = getValue(tbConferenceCharge);
lodgingCharges=double.Parse(tbLodging.Text);
//calculating total expenses
totalExpense=numberOfDays*(lodgingCharges+amountOfCarRental+amountOfParkingFees+amountOfTaxiCharges)+amountOfAirfare+conferenceFees;
//calculating total allowable
totalReimbursement = numberOfDays * (37 + 10 + 20 + 95) + (0.27 * numberOfMilesDriven);

//checking whether expense is more than allowable
if (totalExpense > totalReimbursement)
{
extra = totalExpense - totalReimbursement; //setting extra money to pay
}
else
{
saved = totalReimbursement - totalExpense; //setting money saved
}
//setting textbox values
tbExcessMoney.Text = extra.ToString();
tbTotalExpense.Text = totalExpense.ToString();
tbAmountSaved.Text = saved.ToString();
tbAllowable.Text = totalReimbursement.ToString();
}catch(Exception exp){
//error message for non double input
MessageBox.Show("Please give proper input." + exp.Message);
}
}
}

private double getValue(TextBox tb)
{
//setting value based on input
//if no input is given then 0 is set
if (tb.Text.Equals(""))
{
return 0;
}
else
{
return double.Parse(tb.Text);
}
}


}
}

Output:


Related Solutions

***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...
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...
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...
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...
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...
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
Create a PowersTable application that displays a table of of powers. ( Java Programing )
Create a PowersTable application that displays a table of of powers. ( Java Programing )
Create a CubesSum application that prompts the user for a non-negative integer and then displays the...
Create a CubesSum application that prompts the user for a non-negative integer and then displays the sum of the cubes of the digits.   b) Modify the application to determine what integers of two, three, and four digits are equal to the sum of the cubes of their digits.(Java Programming )
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT