I have 2 functions: one has to calculate the total number of days spent on a trip and the other has to calcualte the time of departure on the first day of the trip and the arrival back home on the last day of the trip. In the first function, don you calculate the total number of days just by cin and return to that function? Im totally lost on how to calculate the time of departure on the first day....i'm thinking that there is some type of pre-processor directive for the date and time but I cant think of it...can anyone offer any suggestions?
cassie_sanford 1 Junior Poster in Training
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
I have 2 functions: one has to calculate the total number of days spent on a trip and the other has to calcualte the time of departure on the first day of the trip and the arrival back home on the last day of the trip.
OK, so far
In the first function, don you calculate the total number of days just by cin and return to that function?
Don know. We have no information on the design specs of the program. You certainly could do it using cin.
Im totally lost on how to calculate the time of departure on the first day....i'm thinking that there is some type of pre-processor directive for the date and time but I cant think of it...can anyone offer any suggestions?
We have no idea how your 'time' is stored. If it's in seconds, you do one thing. If it's in 'time format' you do something else.
cassie_sanford 1 Junior Poster in Training
I think that the time should be displayed in military time format.
Here is the assignment: Write a program that calculates and displays the total travel expenses of a businessperson on a trip. The program should have functions that ask for and return the following:
§ The total number of days on the trip.
§ The time of departure on the first day of the trip, and the time of arrival back home on the last day of the trip. (Use float variables to represent the time of day, with the whole number representing hours, and the decimals representing minutes.)
§ The amount of any round trip airfare.
§ The amount of any car rentals.
§ Miles driven, if a private vehicle was used. Calculate the vehicle expense as $0.27 per mile driven.
§ Parking fees (The company allows up to $6 per day. Anything in excess of this must be paid by the employee.)
§ Taxi fees, if a taxi was used anytime during the trip (The company allows up to $10 per day, for each day a taxi was used. Anything in excess of this must be paid by the employee.)
§ Conference or seminar registration fees.
§ Hotel expenses (The company allows up to $90 per night for lodging. Anything in excess of this must be paid by the employee.)
§ The amount of each meal eaten. On the first day of the trip, breakfast is allowed as an expense if the time of departure is before 7 a.m. Lunch is allowed if the time of departure is before 12 noon. Dinner is allowed on the first day if the time of departure is before 6 p.m. On the last day of the trip, breakfast is allowed if the time of arrival is after 8 a.m. Lunch is allowed if the time of arrival is after 1 p.m. Dinner is allowed on the last day if the time of arrival is after 7 p.m. The program should only ask for the amounts of allowable meals. (The company allows up to $9 for breakfast, $12 for lunch, and $16 for dinner. Anything in excess of this must be paid by the employee.)
The program should calculate and display the total expenses incurred by the businessperson, the total allowable expenses for the trip, and the excess that must be reimbursed by the businessperson. (Note that total expenses are the total amount of expenses incurred by the businessperson during the trip, and the total allowable expenses are those expenses that may be reimbursed by the company. The excess that must be reimbursed by the businessperson is the difference between total and allowable expenses. The allowable expenses cannot exceed total expenses.) The calculations for the total expenses, allowable expenses, and the amount reimbursed may be calculated in additional functions or in the main function.
Input Validation: Do not accept negative numbers for any dollar amount or for miles driven in a private vehicle. Do not accept numbers less than 1 for the number of days. Only accept valid times for the time of departure and the time allowed.
tux4life 2,072 Postaholic
Why are there HTML-tags in your post, BTW, ever heard of paragraphs :P ?
It's difficult to read this ...
cassie_sanford 1 Junior Poster in Training
[TEX]
Write a program that calculates and displays the total travel expenses of a business person on a trip. The program should have functions that ask for and return the following:
• The total number of days on the trip.
• The time of departure on the first day of the trip, and the time of arrival back home on the last day of the trip.
• The amount of any round trip air fare.
• The amount of any car rentals.
• Miles driven, if a private vehicle was used. Calculate the vehicle expense as $.27 per mile driven.
• Parking fees(The company allows up to $6 per day. Anything in excess of this must be paid by the employee.)
• Taxi fees, if a taxi was used anytime during the trip. The company allows up to $10 per day, for each day a taxi was used. Anything in excess of this must be paid by the employee.
• Conference or seminar registration fees.
• Hotel expenses. The company allows up to $90 per night for lodging. Anything in excess of this must be paid by the employee.
• The amount of each meal eaten. On the first day of the trip, breakfast is allowed as an expense if the time of departure is before 7 am. Lunch is allowed if the time of departure is before 12 noon. Dinner is allowed on the first day if the time of departure is before 6 pm. On the last day of the trip, breakfast is allowed if the time of arrival is after 8am. Lunch is allowed if the time of arrival is after 1pm. Dinner is allowed on the last day if the time of arrival is after 7pm. The program should only ask for the amounts of allowable meals. The company allows up to $9 for breakfast, $12 for lunch, and $16 for dinner. Anything in excess must be paid by the employee.
The program should calculate and display the total expenses incurred by the person, the total allowable expenses for the trip, and the excess that must be reimbursed by the person.
siddhant3s 1,429 Practically a Posting Shark
Your solution is posted as the announcement of DaniWeb : We only give homework help to those who show effort
This is what it reads:
This forum is meant for discussing programming languages in addition to exchanging code and algorithms. However, it has become a problem where too many students are posting homework problems expecting a quick solution without ever trying for themselves. Not only does this constitute cheating, but it is very discouraging, frustrating, and annoying to everyone who takes valuable time to answer programming support questions.
Though we are all here to help, please don't expect quick solutions to your homework. We'll help you get started, exchange algorithm ideas, how-to's, etc. but only if you show that you're willing to put in effort as well.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.