| | |
Need help with functions
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 57
Reputation:
Solved Threads: 0
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?
•
•
•
•
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?
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.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
•
•
Join Date: Oct 2008
Posts: 57
Reputation:
Solved Threads: 0
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.
Last edited by Ancient Dragon; Apr 22nd, 2009 at 6:58 pm. Reason: replaced text tags with quote tags
•
•
Join Date: Oct 2008
Posts: 57
Reputation:
Solved Threads: 0
[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.
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.
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 is what it reads:
•
•
•
•
Originally Posted by Administrator of DaniWeb
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.
Siddhant Sanyam
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
![]() |
Similar Threads
- VB's Left, Right, Mid Functions in C++? (C++)
- User defined functions (C++)
- Double Linked Lists and Functions required (C++)
- How to write FNVAL functions (Java)
- I dont see any difference between these 2 functions, DO YOU? (C)
- access Digital Camera Functions (C++)
Other Threads in the C++ Forum
- Previous Thread: need to get time::
- Next Thread: Nested Linked List Class?
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets







?