need help wiv c++ assignment part 2

Discussion in 'C++' started by ricflair, Jan 3, 2011.

  1. ricflair

    ricflair New Member

    Joined:
    Jan 3, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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();
    };
     
  2. jimblumberg

    jimblumberg New Member

    Joined:
    May 30, 2010
    Messages:
    120
    Likes Received:
    29
    Trophy Points:
    0
     
  3. ricflair

    ricflair New Member

    Joined:
    Jan 3, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    im havin problems puttin it on the forum
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    What kind of problem? You have only one restriction of having links and nothing more than that.
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    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;
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice