Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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 PAPER

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago

Question

understand the key issues concerning international assignments

Answered: 1 week ago