0
help me! C# (calculation fuel).
https://code.sololearn.com/cc99MMi5zN03/?ref=app Little John wants to calculate and show the amount of spent fuel liters on a trip, using a car that does 12 Km/L. For this, he would like you to help him through a simple program. To perform the calculation, you have to read spent time (in hours) and the same average speed (km/h). In this way, you can get distance and then, calculate how many liters would be needed. Show the value with three decimal places after the point.
13 Respostas
+ 2
abacatinho
where is second input speed?
+ 2
You have to get two inputs, then use the formula and calculate the litres needed. I see you are only getting input for the time, you didn't get input for the speed. Get both the inputs to use the formula right. And also, you have to do explicit conversion from double to float in line 22. Here, I've fixed your code
https://code.sololearn.com/cZ9pm6YLxXNf/?ref=app
+ 2
Rishi
There is no error. I think he is doing something else.
+ 1
Rishi How do I print the result with three numbers after the comma?
+ 1
abacatinho how are you saying? I don't understand. What are those three numbers and how do you want to print them? Show an example output
+ 1
Rishi.
Output
Print how many liters would be needed to do this trip, with three digits after the decimal point.
Input Sample
10
85
2
92
22
67
Output Sample
70.833
15.333
122.833
+ 1
abacatinho you can do this by using the Round method of Math class. It's very simple, look at the below code, I've given the value and the number of digits to be rounded to the function
https://code.sololearn.com/cqmHDoZair3t/?ref=app
+ 1
Rishi. these differences appeared in my code, for the program to accept I would have to match the outputs.
### files dont match - see output
*** 1017-a.out 2021-12-20 09:18:38.799704743 +0000
--- 1017/1017-a.sol 2015-02-11 17:52:06.454534000 +0000
***************
*** 1 ****
! 72
--- 1 ----
! 72.000
Differences were found
### files dont match - see output
*** 1017-e.out 2021-12-20 09:18:42.631735663 +0000
--- 1017/1017-e.sol 2015-02-11 17:52:06.154534000 +0000
***************
*** 1 ****
! 87
--- 1 ----
! 87.000
Differences were found
+ 1
abacatinho what's this? An error message? Where did you execute this code?
+ 1
Rishi I'm doing this activity and the platform only accepts response with exit and input requested
+ 1
abacatinho well, I don't understand this error.
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ can you find the error here?
+ 1
abacatinho as AJ is saying, your latest code doesn't have any error. Check it again
0
Input
The input file contains two integers. The first one is the spent time in the trip (in hours). The second one is the average speed during the trip (in Km/h).
Output
Print how many liters would be needed to do this trip, with three digits after the decimal point.
Input Sample
10
85
2
92
22
67
Output Sample
70.833
15.333
122.833