New course! Every coder should learn Generative AI!
Try a free lesson0
Skee Ball problem
#include <stdio.h> int main() { int p; int t; scanf("%d%d", &p, &t); t=(p/12); if(t>=40){ printf("Buy it!"); }else{ printf("Try again"); } return 0; } This is my attempt to solve the skee ball problem.All test case ok without one test case.Need your suggestions.
3 Answers
+ 2
Try this:
#include <stdio.h>
int main() {
int score;
int price;
int result;
scanf("%d%d", &score, &price);
result =(score/12);
if(result >= price){
printf("Buy it!");
}else {
printf("Try again");
}
return 0;
}
+ 1
points is first input
cost is second input
tickets = points / 12
if tickets >= cost
Buy it!
else
Try again
you're taking t as an input for the cost and then setting it to the tickets and comparing all ticket calculations to a cost of 40 which you don't know
0
My Python code :
points= int(input())
cost = int(input())
tickets = points / 12
if tickets >= cost:
print("Buy it!")
else:
print("Try again")