# Thread: Thinking About Programming - A Guide for Beginners ?!?!? little problem

1. ## Thinking About Programming - A Guide for Beginners ?!?!? little problem

well the Thinking About Programming - A Guide for Beginners
I gain trough mail I try it out

well I could do alone all except to break the program if
Code:
`(video1 && video2) < 1`
or something like that

well problem occurs with days

I gave that lot if cuz if 1 day cannot be 1 days

so that if you say 1 day it musnt come out 1 days

and when I try to put in
Code:
`(video1 && video2) < 1`
it's problem cuz it doesn't look at all other if-s

how could I repair this problem???
I'm out of ideas

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)
{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
{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;
}``` 2. Code:
`(video1 && video2) < 1`
I don't think that code does what you think it does. Do you mean to do this instead?
Code:
`if( video1 < 1 && video2 < 1)` 3. 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``` 4. ## got it

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)
{}

else if (video1 > 0 || video2 > 0)
{
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\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;
}``` 5. ## you could probably simplify your final output section by using the >= operator, you could do away with the seperate '==' test and just use two if else statements
Code:
```
else if (video1 > 0 || video2 > 0)
{
if (video1 >= 1)
{
cout << "\n\n\nvideo 1 is rented for: "<< video1 <<" day(s)\n";
}
else
{
cout << "\n\n\nvideo 1 is not rented\n";}
}
if (video2 >= 1)
{
cout << "video 2 is rented for: "<< video2 <<" day(s)\n\n";
}
else
{
cout << "video 2 is not rented\n\n";
}

// results.....
// results.....
}``` Popular pages Recent additions 