Code:
#include <iostream>
using namespace std;
int main ()
{
int x;
int y;
int video1;
int video2;
cout << "we have 2 available videos to rent\n\n";
cout << "1 - yes\n_____________________\n1. video costs 2.00$ |\n";
cout << "2. video costs 3.00$ |\n";
cout << "_____________________|\n";
cout << "\n\n\n\n2 - no\n_____________________\nexit |\n";
cout << "_____________________|\n\n\n\n\n";
cout << "would you like to rent any of videos?\n";
cin >> x;
if (x == 2)
{cout <<"good bye\n";}
else if (x == 1)
{
cout << "\n\nwould you like to rent video1?\n";
cout << "this video costs 2.00 $\n";
cout << "for how many days would you like to rent video 1\n";
cin >> video1;
cout << "\n\nwould you like to rent video 2?\n";
cout << "this video costs 3.00$";
cout << "for how many days would you like to rent video 2\n";
cin >> video2;
if( video1 < 1 && video2 < 1)
{cout << "if this couts it has to break every else if-s\n";}
if (video1 > 1)
{cout << "\n\n\nvideo 1 is rented for: "<< video1 <<" days\n";}
else if (video1 == 1)
{cout << "\n\n\nvideo 1 is rented for: "<< video1 <<" day\n";}
else if (video1 < 1)
{cout << "\n\n\nvideo 1 is not rented\n";}
if (video2 > 1)
{cout << "video 2 is rented for: "<< video2 <<" days\n\n";}
else if (video2 == 1)
{cout << "video 2 is rented for: "<< video2 <<" day\n\n";}
else
{cout << "video 2 is not rented\n";}
cout << "total cost of video 1 is: " << video1*2.00 << "$\ntotal cost of video 2 is: " << video2*3.00 << "$\n\n";
cout << "total cost is: " << video1*2.00 + video2*3.00 <<"$\n";
}
system ("pause");
return 0;
}
well its still does same as before
problem occurs when I give 0 video1, 0video2
I have to break the program
if I give other only else if
I gain only 1 not 2
like this
Code:
video1 is rented for X day/s/video 1 is not rented
and I need both
Code:
video1 is rented for X day/s/video1 is not rented
video2 is rented for X day/s/video2 is not rented