+ 1
Skee ball 1 from 5 tests not passed
Whats problem please? Listing of c++ code below: #include <iostream> using namespace std; int main() { int scores, price, bool_1; cin >> scores >> price; bool_1 = scores / (12 * price); if (bool_1 >0) cout << "Buy it!"; else cout << "Try again"; return 0; }
6 Respuestas
+ 5
Your problem is that scores / (12 * price) will always be greater than 0. instead try changing the condition to:
if((price * 12) <= scores)
+ 1
Change the condition in 'if' statement, bool_1 is always greater than 0 so it always print "By it".
Try this :
#include <iostream>
using namespace std;
int main() {
int scores, price, bool_1;
cin >> scores >> price;
bool_1 = scores / (12 * price);
if (bool_1 >= 1)
cout << "Buy it!";
else
cout << "Try again";
return 0;
}
+ 1
Thank's Kylie! Code is working.
+ 1
Thank you Maharnab Saikia!
I was stumped after trying to change it up a few different ways for C. I had
if (tickets > cost)
{
printf("%s", buy);
return 0;
After seeing your comment and adding the = character it worked.
if (tickets >= cost)
{
printf("%s", buy);
return 0;
It passed the one. Thanks you!
0
Сергей Румянцев
Your code does not work for price = 0.
Am I right tht only one test case fails?