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
No 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.
Lothar yes , that's what I hinted in my first comment
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 :)
You're right, Lothar. All these code coach posts, it's starting to become a huge blur. 🥴
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
Any body is to learn with me
No problem Richard We could have given you the code but we want you to do it yourself 😎
How do I generate a list with <N> unique elements randomly selected from another (already existing) list?
Given three integer matrices A(m*n),B(m*n) and C(m*n) . Print the one with more zero elements. beside code
I'm coding this for hours & can't make the value of the 5 random numbers round off to 2 decimal places like in the examples
Overloading + operator
( NEED HELP ) Halloween candy