need help wiv c++ assignment part 2

ricflair's Avatar, Join Date: Jan 2011
Newbie Member
im not too good wiv c++ but i need help wiv an asssignment due in very soon...but i need help with an area in particular
The idea is that the clerk should be able to ask the customer for the starting date to rent the car and the project date of the end of lease. Of course, you (the programmer) must calculate the number of days, find out if the date range falls on a week-end or on a week days. If the date range is more than 5 days, the rate should be lower than that of 5 days, which should be lower than the rate for 3 days; in fact the rate should even be lower if the customer wants the car for 20 days or more, which would apply a (low) monthly rate.
main.cpp
#include "Customer.h"
#include "Car.h"
#include "Invoice.h"


void main()
{
Invoice Order;
Order.ProcessOrder();
Order.ShowOrder();
};
jimblumberg's Avatar
Ambitious contributor
[QUOTE][Of course, you (the programmer) must calculate the number of days, find out if the date range falls on a week-end or on a week days/QUOTE]

So where is the code for the above requirement?

Jim
ricflair's Avatar, Join Date: Jan 2011
Newbie Member
im havin problems puttin it on the forum
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by ricflair View Post
im havin problems puttin it on the forum
What kind of problem? You have only one restriction of having links and nothing more than that.
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
First are you able to do it on paper? If you can't do that you have no chance of being able to program it. Do you understand the requirements?

Do you know how to subtract dates to get a number of days?
Presumably you must have the actual rates somewhere, or does the teacher want you to assume some values?

Start at the beginning and write a little bit of code before trying to do the next. Just prompt for the two dates and display them. Compile and run it before moving on. Then add code to subtract the dates and display the number of days between the dates.

The requirement refers to weekends briefly; is there a separate weekend rate? For example would a Tuesday-Thursday hire differ in price from a Friday-Sunday hire? If so then you will also need code that determines what day a specific date is. Does the weekend rate affect an N-day hire, for example would Mon-Fri differ from Thu-Mon?

Hint: have different daily rates that are selected according to the length of the hire. Then all you need to do after calculating the number of days is to select the appropriate rate and multiply the rate by the number of days, e.g.:
Code:
int rateMAX=1; // you probably want to use doubles not ints, this is just illustrative
int rate20=5;
int rate5=10;
int rate3=20;

int days=subtractDates(date1, date2);
int rate=0;
if (days<=3) rate=rate3;
else if (days<=5) rate=rate5;
else if (days<=20) rate=rate20;
else rate=rateMAX;

int totalCost=rate*days;