+ 1

Why not work? How i can resolve this, I'm noob sorry

https://www.sololearn.com/coach/22?ref=app cost = 40 ccolor = 5 ncolor = gets.to_i subtotal = cost + (ccolor * ncolor) totaltax = subtotal / 10 total = subtotal + totaltax puts total Why not work? How i can resolve this, I'm noob sorry

28th Jan 2020, 2:32 PM
cono nico coco
15 Respostas
+ 2
No prob Richard Alfonzo I could have given you the code but I wanted you to do it yourself 👍
28th Jan 2020, 3:21 PM
Daljeet Singh
Daljeet Singh - avatar
+ 7
As the task description says, the result shown as output should be rounded UP to the nearest whole number. The method in ruby for this is ".ceil".
28th Jan 2020, 4:21 PM
Lothar
Lothar - avatar
+ 7
Python: clc = int(input()) cst = round(((clc * 5.0)+40.0)*1.1) print(cst) Ruby: clc = gets.to_i cst = (((clc * 5.0)+40.0)*1.1).round() puts cst
28th Jan 2020, 5:23 PM
Michail Getmanskiy
Michail Getmanskiy - avatar
+ 7
HonFu Lothar I wouldn’t be so categorical about these codes of the trainer ... the fact that the description of the problem doesn’t quite accurately describe it can be considered a plus that increases the complexity of the search for the required solution a little ... in real life it’s a rarity to absolutely clearly and correctly describe the task ... usually if there is such a description, then the problem has already been solved. yes, and unfortunately, this section is no longer developing..🤔
28th Jan 2020, 8:05 PM
Michail Getmanskiy
Michail Getmanskiy - avatar
+ 6
An other issue is the division in your code. In ruby the following results are given: puts 5 / 10, "\n" # returns 0 puts 5 / 10.0, "\n" # returns 0.5 To get a float you have to divide by "10.0", and later on you have to use the .ceil method to get the result.
28th Jan 2020, 4:32 PM
Lothar
Lothar - avatar
+ 3
Lothar yes , that's what I hinted in my first comment
28th Jan 2020, 4:39 PM
Daljeet Singh
Daljeet Singh - avatar
+ 2
I don't know Ruby well. Does this come out as a float? They only want two decimal places in the output then.
28th Jan 2020, 2:37 PM
HonFu
HonFu - avatar
+ 2
Have you tested your code with different manual inputs? If not, do that. See if it comes out like a price should, with decimals, but only two.
28th Jan 2020, 3:20 PM
HonFu
HonFu - avatar
+ 2
I have achieved it, with round and abs and a small change in the formula, thank you very much for the help :)
28th Jan 2020, 3:21 PM
cono nico coco
+ 2
You're right, Lothar. All these code coach posts, it's starting to become a huge blur. 🥴
28th Jan 2020, 4:23 PM
HonFu
HonFu - avatar
+ 1
Richard Alfonzo you have to use round() try and come back edit hint : cost 40.00. Each color of paint that you buy is an additional 5.00
28th Jan 2020, 2:54 PM
Daljeet Singh
Daljeet Singh - avatar
+ 1
I try with round and abs and when I test the cases, I only exceed 2 of the 5, I don't know why, I also can't see which is the wrong entry :(
28th Jan 2020, 3:13 PM
cono nico coco
0
"Output Format A number that represents the cost of your purchase rounded up to the nearest whole number." I think the problem is the result has to be an integer, I don't know how to convert the output to an integer or that the input is an integer
28th Jan 2020, 2:52 PM
cono nico coco
0
Any body is to learn with me
30th Jan 2020, 10:17 AM
K Lokanath
K Lokanath - avatar
- 2
No problem Richard We could have given you the code but we want you to do it yourself 😎
29th Jan 2020, 8:52 AM
CodeBreaker
CodeBreaker - avatar