Hi Can you help with this exercice. (I'm not allowed to modify neither the begining or the end of the program). I have a problem when the renting cost calculation is done using both rates. The rental rates are as follows:
From 00:00 to 07:00 and from 17:00 to 24:00: 1 Franc/hour;
From 07:00 to 17:00: 2 Francs/hour.
**************************************************************
#include <iostream>
using namespace std;
int main()
{
cout << "Donnez l'heure de début de la location (un entier) : ";
int debut(25);
cin >> debut;
cout << "Donnez l'heure de fin de la location (un entier) : ";
int fin(25);
cin >> fin;
/*****************************************************
* Compléter le code à partir d'ici
*****************************************************/
if ((fin>24) or (debut>24 and debut<0)){
cout << "Les heures doivent être comprises entre 0 et 24 !" << endl;
}
if (fin==debut){
cout << "Bizarre, vous n'avez pas loué votre vélo bien longtemps !" << endl;
}
if (debut>fin){
cout << "Bizarre, le début de la location est après la fin ..." << endl;
}
if ((debut>=0 and debut<7) or (debut>17 and debut<24)){
if ((fin>0 and fin<7) or (fin>17 and fin<=24)){
cout << "Vous avez loué votre vélo pendant" << endl;
cout << fin - debut << " heure(s) au tarif horaire de " << " 1 franc(s)" << endl;
cout << "Le montant total à payer est de " << fin - debut << " franc(s)." << endl;
}
}
if (debut>7 and debut <17){
if (fin>7 and fin <17){
cout << "Vous avez loué votre vélo pendant" << endl;
cout << fin - debut << " heure(s) au tarif horaire de " << " 2 franc(s)" << endl;
cout << "Le montant total à payer est de " << 2*(fin - debut) << " franc(s)." << endl;
}else{
cout << "Vous avez loué votre vélo pendant" << endl;
cout << fin-17 << " heure (s) au tarif horaire de " << " 1 franc (s) " << endl;
cout << 17-debut << " heure (s) au tarif horaire de " << " 2 franc (s) " << endl;
cout << "le montant total à payer est de " << (fin-17) + 2*(17-debut) << " franc (s)."<< endl;
}
}else{
cout << "Vous avez loué votre vélo pendant" << endl;
cout << 7-debut << " heure(s) au tarif horaire de " << " 1 franc(s)" << endl;
cout << fin-7 << " heure (s) au tarif horaire de " << " 2 franc (s) " << endl;
cout << "le montant total à payer est de " << (7-debut)+2*(fin-7) << " franc (s). " << endl;
}
/*******************************************
* Ne rien modifier après cette ligne.
*******************************************/
This is not a free homework site. Please, be specific about the problems that you are having. Show your code. Once you show us the code with specific questions, we may be able to help you. Contrary to popular belief, humans are the ones behind the keyboards with personal lives and do not do things for free.