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
1/28/2020 2:32:22 PM
cono nico coco
15 Answers
New AnswerNo prob Richard Alfonzo I could have given you the code but I wanted you to do it yourself 👍
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".
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
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..🤔
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.
I don't know Ruby well. Does this come out as a float? They only want two decimal places in the output then.
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.
I have achieved it, with round and abs and a small change in the formula, thank you very much for the help :)
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
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 :(
"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
No problem Richard We could have given you the code but we want you to do it yourself 😎