Need help with functions

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 57
Reputation: cassie_sanford is an unknown quantity at this point 
Solved Threads: 0
cassie_sanford cassie_sanford is offline Offline
Junior Poster in Training

Need help with functions

 
0
  #1
Apr 22nd, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,117
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: Need help with functions

 
0
  #2
Apr 22nd, 2009
Originally Posted by cassie_sanford View Post
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

Originally Posted by cassie_sanford View Post
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.

Originally Posted by cassie_sanford View Post
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.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 57
Reputation: cassie_sanford is an unknown quantity at this point 
Solved Threads: 0
cassie_sanford cassie_sanford is offline Offline
Junior Poster in Training

Re: Need help with functions

 
0
  #3
Apr 22nd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 1,968
Reputation: tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute 
Solved Threads: 214
tux4life's Avatar
tux4life tux4life is offline Offline
Posting Virtuoso

Re: Need help with functions

 
0
  #4
Apr 22nd, 2009
Why are there HTML-tags in your post, BTW, ever heard of paragraphs ?
It's difficult to read this ...
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 57
Reputation: cassie_sanford is an unknown quantity at this point 
Solved Threads: 0
cassie_sanford cassie_sanford is offline Offline
Junior Poster in Training

Re: Need help with functions

 
0
  #5
Apr 22nd, 2009
[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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 793
Reputation: siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of 
Solved Threads: 135
siddhant3s's Avatar
siddhant3s siddhant3s is offline Offline
Master Poster

Re: Need help with functions

 
0
  #6
Apr 23rd, 2009
Your solution is posted as the announcement of DaniWeb : We only give homework help to those who show effort
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC