Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write the coding clearly.I need to understand how to solve this question. 12 CS/MAR 2013/CSC125/128/1TC120 CONFIDENTIAL QUESTION 2 The following table shows the average
Please write the coding clearly.I need to understand how to solve this question.
12 CS/MAR 2013/CSC125/128/1TC120 CONFIDENTIAL QUESTION 2 The following table shows the average speed per hour for two types of vehicles Vehicle Average Speed Code 120 km/h 2 75 km/h a) Write the definition of a function named CalcDistance ) that receives the vehicle code and time travelled in minutes. The function will calculate and return the distance travelled in kilometer for that type of vehicle. The formula to calculate the distance travelled is as follows. Distance Travelled (km) = Average Speed . (Time traveled/60) (4 marks) b) Write the definition of a function named CalcFuelConsumption) that receives the distance travelled in kilometer and fuel usage in liter. The function will calculate and return the fuel consumption in liter per kilometer that has been used by that particular type of vehicle. The formula to calculate the fuel consumption is as follows: Fuel Consumption (liter/km) Fuel Usage/ Distance Travelled (4 marks) c) Write a main program that requires the user to enter the vehicle code, time travelled in minutes and fuel usage in liter. The program will call all of the functions above to calculate the distance travelled in kilometer and the fuel consumption in liter per kilometer used by the vehicle. Later, the program will print all of the information of the vehicle as shown in the example below Vehicle Code Time travelled Distance travelled Fuel usage Fuel consumption 120 minutes 240 km 50 liter 0.208333 liter/km (7 marks) END OF QUESTION PAPERStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started