+ 1
Paint costs.
https://sololearn.com/coach/22/?ref=app Either 4/5 or 3/5. Why can’t I get 5/5? Any ideas?
9 Antworten
0
int main() {
int canvas = 40;
int color = 5;
int colors;
cin >> colors;
int total = canvas + (colors*color);
double with_tax = total + (total*0.1);
//int with_tax = total + (total*0.1);
cout << int(round(with_tax))<< endl;
return 0;
}
Guys, we got him!
5/5.
Now I don’t care why this does work?😂
+ 6
cout << int(round(with_tax))<< endl;
+ 3
Can you please show your attempt.
+ 2
#include <math.h>
And then
round(with_tax)
"Output Format
A number that represents the cost of your purchase rounded up to the nearest whole number."
+ 2
What? But I just did ...
Could it be because you store it as a double? Try rounding first then storing it as int
0
int main() {
int canvas = 40;
int color = 5;
int colors;
cin >> colors;
int total = canvas + (colors*color);
//double with_tax2 = total + (total*0.1); (with this I am getting first two test correct)
int with_tax = total + (total*0.1);(with this, first two and fifth one is correct)
cout << with_tax<< endl;
(If I try to print with round(with_tax), I get first 4 tests correct.)
//cout<< with_tax2<<endl;
return 0;
}
0
Cristian Gabriel Mazzulla
#include <iostream>
#include<cmath>
using namespace std;
int main() {
int canvas = 40;
int color = 5;
int colors;
cin >> colors;
int total = canvas + (colors*color);
double with_tax = total + (total*0.1);
//int with_tax = total + (total*0.1);
cout << round(with_tax)<< endl;
//cout<< with_tax2<<endl;
return 0;
}
With some changes, it’s 4/5.
The first 4 tests passed.
0
5/5
- 1
#include <stdio.h>
#include<math.h>
int main() {
int x,r;
float c,y;
scanf("%d",&x);
c=(x*5)+40;
y=c+c/10;
r=round(y);
printf("%d",r);
return 0;
}