#Lua cars assemble task 1 wrong
18 messages · Page 1 of 1 (latest)
Could you share your code and the test details as text in a codeblock and not as an image? Images are hard to copy paste from, or even hard to read for many people.
ok
-- returns the amount of working cars produced by the assembly line every hour
function cars.calculate_working_cars_per_hour(production_rate, success_rate)
-- calculate_working_cars_per_hour body
return production_rate * (success_rate / 100)
end```
cars.calculate_working_cars_per_hour(1547, 90)
--> => 1392.3
Note: the return value should be a float.```
Is there a test failure you're getting? Can you share that in a codeblock too?
assert.are.equal(0.0, cars_assemble.calculate_working_cars_per_hour(0, 100))
assert.are.equal(221.0, cars_assemble.calculate_working_cars_per_hour(221, 100))
assert.are.equal(340.8, cars_assemble.calculate_working_cars_per_hour(426, 80))
assert.are.equal(1398.92, cars_assemble.calculate_working_cars_per_hour(6824, 20.5))
assert.are.equal(0.0, cars_assemble.calculate_working_cars_per_hour(8000, 0))
TEST FAILURE
Expected objects to be equal.
Passed in:
(number) 340
Expected:
(number) 340.80000000000001137```
Are you returning an integer instead of a float?
- Do you understand what the test is doing?
- Do you understand what the test is expecting and why?
- Do you understand what your code returns and how it differs?
- Do you understand why your code is returning what it returns?
float
something is wrong with that preveous test failure. heres what it says now : assert.are.equal(0.0, cars_assemble.calculate_working_cars_per_hour(0, 100)) assert.are.equal(221.0, cars_assemble.calculate_working_cars_per_hour(221, 100)) assert.are.equal(340.8, cars_assemble.calculate_working_cars_per_hour(426, 80)) assert.are.equal(1398.92, cars_assemble.calculate_working_cars_per_hour(6824, 20.5)) assert.are.equal(0.0, cars_assemble.calculate_working_cars_per_hour(8000, 0)) TEST FAILURE Expected objects to be equal. Passed in: (number) 1398.9199999999998454 Expected: (number) 1398.9200000000000728
Did the code change, too, or is this the results from the same code above?
Try doing the multiplication before the division and see if that helps
same code
ill try
it worked
thank you
You're welcome