Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use programming in c to code the following program. Assigment Description: Follow these steps! - Here is an incomplete code to get you started:

please use programming in c to code the following program.
Assigment Description:
image text in transcribed
Follow these steps!
image text in transcribed
-
Here is an incomplete code to get you started:
image text in transcribed
Calculate the cost of gas and the time it will take for a road trip. Assume the user will drive an average of 70 MPH. The user will enter the number of miles, the cost of gas per gallon, and the miles per gallon(mpg) of the car. //Calculate the cost of the gas on a trip //declare, ask, and get the price per gallon and the mpg //calculate and return (by reference) the cost of gas for the number of miles passed to the function void GasCost (double miles, double gasTotalPtr) //using a 75 MPH speed limit and the miles passed to the function //calculate and return (by reference) the total time it wil1 take as a double //And also calculate the number of hours and number of minutes void TripTime (double miles, double 'totalTimePtr, int hoursPtr, int minutesPtr) Main function logic: declare 3 double variables (miles, gas, time declare 2 integer variables (hours, minutes) ask and get the number of miles // pass the miles (by copy) and the "address of" gas to the GasCost function /Tell the user how much the gas will cost /pass the miles, "address of time, "address of hours, and "address of" minutes /Tell the user how much total time it will take as a double (time) also tell the user how many hours and how many minutes that is 6. Be sure to add a Greeting (a Greeting function may be added) 7. Ask and get a value for the number of miles (You may add a function for this) **build run and test 8. Now t is time to implement the GasCost function definition. Create the function definition (block of code) below the main function Inside the function you will need to get the price per gallon from the user . .Inside the function you will also need to get the miles per gallon (MPG) of the user's car Make the total gas calculation for the number of miles (argument 1) and store the result in the "value at" gasTotalPtu ** build run and test 9. Now it is time to test the GasCost function with a function call 10. Write the statement to call the GasCost function from inside the main function and pass the miles and the "address of" gas to the function 11. Print gas onto the screen from the main function to see the total **build run and test 12. Now it is time to implement the TripTime function definition. Create the function definition (block of code) below the main function the "value at" totalTimePtr at" hours and value at" minutes Inside the function you will need to calculate total time using miles and speed 70MPH store the result in Inside the function you will also need calculate how many hours and how many minutes stored in "value One way to do the calculation int HOURS = (int)TOTAL TIME //cast the totaltme to an integer to get the number of hours int MINUTES (TOTALTIME-HOURS) 60;subtract the hours from the total time and multiply by 60 to get the number of minutes build run and test 13. Now it is time to test the TripTime function with a function call 14. Write the statement to call the TripTime function from inside the main function and pass the miles and the address of" time, "address of hours, and "address of" minutes to the function 15. Print the results onto the screen from the main function build run and test BEFORE SUBMITTING THE CODE //Add name, date, and description here //preprocessor directives #de fine CRT SECURE NO WARNINGS #include //Calculate the cost of the gas on a trip //declare, ask, and get the price per gallon and the mpog //calculate and return (by reference) the cost of gas for the number of miles passed to the function void GasCost (double miles, double gasTotalPtr); //using a 70 MPH speed limit and the miles passed to the function //calculate and return (by reference) the total time it will take as a double //And also calculate the number of hours and number of minutes void TripTime (double miles, double *totalTimePtr, int *hoursPtr, int *minutesPtr); int main() //Greet the user //declare 3 double variables (miles, gas, //declare 2 integer variables (hours, //see the assignment instructions for more time) minutes) details return 0 //function definitions

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_2

Step: 3

blur-text-image_3

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

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions

Question

demonstrate the importance of induction training.

Answered: 1 week ago