--> Fuel Spent (beeCrowd- 1017) URI 1017 Solution C, Python | Alpha Codist

Search This Blog

Fuel Spent (beeCrowd- 1017) URI 1017 Solution C, Python

This problem is from beecrowd fuel spent c python 1017 solution solved fuel needed calculation average speed spent time consumption .3f % digits three

Fuel Spent

This problem is from beecrowd fuel spent c python 1017 solution solved fuel needed calculation average speed spent time consumption .3f % digits three

This problem is from beeCrowd. Here, The average speed is given as it is 12 km/L. All you have to do is to take two inputs as integers, calculate how much fuel is needed and print the value with 3 digits after the decimal points.

The formula is:

1. Take input.

2. Calculate the amount of fuel needed with this formula:

fuel_needed = (average_speed * spent_time) / consumption

3. Print the value of fuel_needed with three digits after the decimal point. In C programming using "%0.3f" will print 3 digits after the decimal point. And in Python, it is the same. The difference between this two is how you print them. Let's see the solution.


The solution in C:


#include <stdio.h>
 
int main() {
 
    double consumption,fuel_needed;
    int spent_time,average_speed;
    
    scanf("%d %d",&spent_time, &average_speed);
    
    consumption = 12.000;
    
    fuel_needed = ((double) average_speed * (double) spent_time)/consumption;
    
    printf("%0.3f\n",fuel_needed);
    
    return 0;
}


The solution in Python:


spent_time = int(input())
average_speed = int(input())

consumption = 12


fuel_needed = (average_speed * spent_time) / consumption

print("%0.3f" % fuel_needed)

COMMENTS

Name

beeCrowd,11,C,10,Computer,9,Downloads,3,HTML,1,My Creation,2,Python,24,Python-Soft,1,Shooting,2,
ltr
item
Alpha Codist: Fuel Spent (beeCrowd- 1017) URI 1017 Solution C, Python
Fuel Spent (beeCrowd- 1017) URI 1017 Solution C, Python
This problem is from beecrowd fuel spent c python 1017 solution solved fuel needed calculation average speed spent time consumption .3f % digits three
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7hHGfbwMvVTc6Tvnqf_ydQbctKbOfD-RD0BWkV3-f2u2-i8zkg3tDs3C3cILExyqajmK7EYCq-p44Dwh2FS94IREjjqdpKGswkK3CxbNUosloLG5KJt1Ldsb2F9ccvYYasD0orP7OxMc0xk6CbbZEEiKjfzVlI95XVH5x6QZen1sZoYmXDbrgFAHF-w/w640-h422/1017.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7hHGfbwMvVTc6Tvnqf_ydQbctKbOfD-RD0BWkV3-f2u2-i8zkg3tDs3C3cILExyqajmK7EYCq-p44Dwh2FS94IREjjqdpKGswkK3CxbNUosloLG5KJt1Ldsb2F9ccvYYasD0orP7OxMc0xk6CbbZEEiKjfzVlI95XVH5x6QZen1sZoYmXDbrgFAHF-w/s72-w640-c-h422/1017.png
Alpha Codist
https://alphacodist.blogspot.com/2022/11/fuelspentbeecrowd1017.html
https://alphacodist.blogspot.com/
https://alphacodist.blogspot.com/
https://alphacodist.blogspot.com/2022/11/fuelspentbeecrowd1017.html
true
7547834254111195316
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content