a) Prompt the user and accept user input for the following information: q Employ
ID: 3532290 • Letter: A
Question
a) Prompt the user and accept user input for the following information:
q Employee Name
q The number of days the user spent on a business trip.
q The total amount spent on meals.
q The total amount spent on airfare.
q The total amount spent on car rentals.
q The total amount spent on hotel bills.
q The total amount of the expense advance the user received.
b) Display a report that displays the following where 9999.99 is replaced with the
correct values based on what was entered by the user in step a) above:
Please note the following:
q Decide on what variables you are going to need for this program and put them in your housekeeping area of your program.
q Allow the user to input the seven fields mentioned above.
q Generate methods that would do the following:
o Calculate the Average Meal Expense which is the total amount spent on meals divided by the number of days.
o Calculate Total Amount Due which is the expense advance minus the total amount spent on the trip.
****** Total Expenses for Employee: XXXXXXXXX XXXXXXXXXXX *******
Meals Airfare Car Rental Hotel
----------------------------------------------------------------------------------
9999.99 9999.99 9999.99 9999.99
Average Meal Expense: 9999.99
Amount of Expense Advance: 9999.99
Total Amount Due: 9999.99
Explanation / Answer
Fully functional application
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string name;
int noOfDays;
int mealamount;
int airfare;
int carrental;
int hotelbills;
int advance;
System.Console.WriteLine("Enter the employee name");
name = System.Console.ReadLine();
System.Console.WriteLine("The number of days the user spent on a business trip");
noOfDays =Convert.ToInt32(System.Console.ReadLine());
System.Console.WriteLine("The total amount spent on meals");
mealamount = Convert.ToInt32(System.Console.ReadLine());
System.Console.WriteLine("The total amount spent on airfare");
airfare = Convert.ToInt32(System.Console.ReadLine());
System.Console.WriteLine("The total amount spent on car rentals");
carrental = Convert.ToInt32(System.Console.ReadLine());
System.Console.WriteLine("The total amount spent on hotel bills");
hotelbills = Convert.ToInt32(System.Console.ReadLine());
System.Console.WriteLine("The total amount of the expense advance the user received");
advance= Convert.ToInt32(System.Console.ReadLine());
System.Console.Write("****** Total Expenses for Employee: XXXXXXXXX XXXXXXXXXXX ******* ");
System.Console.Write("Meals Airfare Car Rental Hotel ");
System.Console.Write("----------------------------------------------------------------------------------" + " ");
System.Console.Write(mealamount + " " + airfare + " " + carrental + " " + hotelbills + " ");
System.Console.Write("Average Meal Expense:" + averagemeal(mealamount, noOfDays)+" ");
System.Console.Write("Amount of Expense Advance:" + advance + " ");
System.Console.Write("Total Amount Due:" + (mealamount + airfare + carrental + hotelbills - advance) + " ");
System.Console.ReadLine();
}
public static float averagemeal(int meal, int days)
{
return (meal / days);
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.