IN C PROGRAMMING PLEASE!!!!' 7.6 LAB*: Program: Fancy car Program Specifications Write a program that uses a struct to s
Posted: Sun Jul 10, 2022 11:23 am
IN C PROGRAMMING PLEASE!!!!'
7.6 LAB*: Program: Fancy car
Program Specifications Write a programthat uses a struct to support basic operations such as drive, addgas, honk horn and start engine. FancyCar.h declares theFancyCar_Struct and the functions necessary to complete theexercise. FancyCar.c provides the function stubs. Follow each stepto gradually complete all functions in FancyCar.c.
Note: This program is designed for incrementaldevelopment. Complete each step and submit for grading beforestarting the next step. Only a portion of tests pass after eachstep but confirm progress. The main() function includes an exampleto be used for development. Add statements in main() as functionsare completed to support development mode testing.
Step 0. Declare data members for milesdriven as shown on the odometer (int), gallons of gas in tank(double), miles per gallon or MPG (double), driving capacity(double), and car model (char[]). Note the provided constantvariable in FancyCar.c indicates the gas tank capacity of 14.0gallons.
Step 1 (2 pts). 1) DefineInitializeFancyCar() to set the odometer to five miles, tank isfull of gas, miles per gallon is 24.0, and the model is "OldClunker". InitializeFancyCar() returns the initialized FancyCarstruct. 2) Complete functions to check the odometer, check the gasgauge, get the model, and get the miles per gallon. Submit forgrading to confirm 1 test passes.
Step 2 (1 pt). Complete the HonkHorn()function to output the car model. If the car model is:
the HonkHorn() function outputs:
Submit for grading to confirm 2 tests pass.
Step 3 (1 pt). Complete the Drive()function. Miles driven should increase by parameter distance, andthe amount of gas should decrease by distance / MPG. Data membersare only updated if parameter distance is positive. Drive() returnsthe updated FancyCar struct. Submit for grading to confirm 3 testspass.
Step 4 (2 pts). Complete the AddGas()function. Increase gas tank by parameter amount only if parameteris positive. Set gas tank to full if too much gas was added.AddGas() returns the updated FancyCar struct. Submit for grading toconfirm 4 tests pass.
Step 5 (2 pts). Update the Drive()function to identify if the car runs out of gas. If so, theparameter distance will not be achieved, and the gas tank will have0.0 gallons. For example, Drive(car, 100) will not be possible withonly three gallons of gas and MPG of 20.0. The maximum drivingdistance is 60 miles with three gallons of gas and MPG of 20.0.Therefore, the odometer will only increase by 60 instead of therequested 100, and the gas tank will have 0.0 gallons (not anegative amount). Submit for grading to confirm 5 tests pass.
Step 6 (2 pts). 1) Add an engine status(int) data member in the FancyCar struct to indicate if the carengine is on or off. 2) Complete the StartEngine() function to setthe engine status to 1 and return the updated FancyCar struct. 3)Complete the StopEngine() function to set the engine status to 0and return the updated FancyCar struct. 4) Update theInitializeFancyCar() function to start with the engine off. 5)Update the Drive() function to only update data members if theengine is on, and the engine turns off if the car runs out of gas.6) Update the AddGas() function to only add gas if the engine isoff. Submit for grading to confirm all tests pass.
LAB ACTIVITY 7.6.1: LAB*: Program: Fancy car 1 #include 2 #include 3 4 #include "FancyCar.h" 5 6 int main(void) { 7 FancyCar car; 8 9 10 11 12 13 14 15 16} char name [100]; strcpy(car.model, "Example"); Current file: main.c GetCarModel (car, name); // Should print: The model of the car is Example // printf("The model of the car is %s.\n", name); return 0; 0/10 Load default template...
7.6 LAB*: Program: Fancy car
Program Specifications Write a programthat uses a struct to support basic operations such as drive, addgas, honk horn and start engine. FancyCar.h declares theFancyCar_Struct and the functions necessary to complete theexercise. FancyCar.c provides the function stubs. Follow each stepto gradually complete all functions in FancyCar.c.
Note: This program is designed for incrementaldevelopment. Complete each step and submit for grading beforestarting the next step. Only a portion of tests pass after eachstep but confirm progress. The main() function includes an exampleto be used for development. Add statements in main() as functionsare completed to support development mode testing.
Step 0. Declare data members for milesdriven as shown on the odometer (int), gallons of gas in tank(double), miles per gallon or MPG (double), driving capacity(double), and car model (char[]). Note the provided constantvariable in FancyCar.c indicates the gas tank capacity of 14.0gallons.
Step 1 (2 pts). 1) DefineInitializeFancyCar() to set the odometer to five miles, tank isfull of gas, miles per gallon is 24.0, and the model is "OldClunker". InitializeFancyCar() returns the initialized FancyCarstruct. 2) Complete functions to check the odometer, check the gasgauge, get the model, and get the miles per gallon. Submit forgrading to confirm 1 test passes.
Step 2 (1 pt). Complete the HonkHorn()function to output the car model. If the car model is:
the HonkHorn() function outputs:
Submit for grading to confirm 2 tests pass.
Step 3 (1 pt). Complete the Drive()function. Miles driven should increase by parameter distance, andthe amount of gas should decrease by distance / MPG. Data membersare only updated if parameter distance is positive. Drive() returnsthe updated FancyCar struct. Submit for grading to confirm 3 testspass.
Step 4 (2 pts). Complete the AddGas()function. Increase gas tank by parameter amount only if parameteris positive. Set gas tank to full if too much gas was added.AddGas() returns the updated FancyCar struct. Submit for grading toconfirm 4 tests pass.
Step 5 (2 pts). Update the Drive()function to identify if the car runs out of gas. If so, theparameter distance will not be achieved, and the gas tank will have0.0 gallons. For example, Drive(car, 100) will not be possible withonly three gallons of gas and MPG of 20.0. The maximum drivingdistance is 60 miles with three gallons of gas and MPG of 20.0.Therefore, the odometer will only increase by 60 instead of therequested 100, and the gas tank will have 0.0 gallons (not anegative amount). Submit for grading to confirm 5 tests pass.
Step 6 (2 pts). 1) Add an engine status(int) data member in the FancyCar struct to indicate if the carengine is on or off. 2) Complete the StartEngine() function to setthe engine status to 1 and return the updated FancyCar struct. 3)Complete the StopEngine() function to set the engine status to 0and return the updated FancyCar struct. 4) Update theInitializeFancyCar() function to start with the engine off. 5)Update the Drive() function to only update data members if theengine is on, and the engine turns off if the car runs out of gas.6) Update the AddGas() function to only add gas if the engine isoff. Submit for grading to confirm all tests pass.
LAB ACTIVITY 7.6.1: LAB*: Program: Fancy car 1 #include 2 #include 3 4 #include "FancyCar.h" 5 6 int main(void) { 7 FancyCar car; 8 9 10 11 12 13 14 15 16} char name [100]; strcpy(car.model, "Example"); Current file: main.c GetCarModel (car, name); // Should print: The model of the car is Example // printf("The model of the car is %s.\n", name); return 0; 0/10 Load default template...