Question: for our C++ lab This is the procedure that needs to be completed.i was hoping it could be completed and i could use it as
for our C++ lab This is the procedure that needs to be completed.i was hoping it could be completed and i could use it as a refrence/ guide for when i get stuck. below this is the code ive been working on so far. (but feel free to start from scratch). the #include options allowed are the ones used in my code. we are using If statements and while loops/do while loops. not sure if it makes a diffrence but the program used is visual studio.


my code so far (not working the way it needs to)
#include
#define _CRT_SECURE_NO_WARNINGS
/******************************************************************************* Main *******************************************************************************/ void purpose(); float getRateMPG(); float getRateL();
void main() { //Variable Declarations/user inputs purpose(); //print the message char type = 'g'; // for metric or imperial (MPG or L/100km) float getRateL();//gets rates from user for L/100km
while ((((type != 'l') && (type != 'L') && (type != 'M') && (type != 'm')))) { char type; printf("Please enter L or l for MPG to L/100km or"); printf(" enter M or m for L/100km to MPG "); fflush(stdin); type = getchar();
if (type == 'L' || type == 'l') { printf("you have chosen to convert MPG to L/100km "); fflush(stdin);
float getRateMPG(); // for getting the rates from user(MPG) } else { if (type == 'M' || type == 'm') { printf(" you have chosen to convert L/100km to MPG "); fflush(stdin); }
else { printf("SORRY BUT THAT WAS NOT ONE OF THE OPTIONS"); printf(" YOU ARE AN IDIOT "); }
} } while (!_kbhit()); }
/******************************************************************************* Purpose - This function prints the purpose of the program to the console.
Inputs: none
Returned: none *******************************************************************************/
void purpose() { printf(" This program will convert MPG to L/100km OR L/100km to MPG "); printf(" depending on the users choice "); }
/******************************************************************************* GetRate - This function gets the rates from the user
Inputs: float
Returned: float *******************************************************************************/ float getRateMPG() { printf("Please enter the Rate between 10-60 MPG: "); fflush(stdin); return getRateMPG(); }
Explain the purpose of the program to the user. Do this in a separate function. Request the type of conversion: MPG to L/100km (accept only L or I) or L/100km to MPG (accept M or m only). Continue to ask the user until the correct selection is made. Do this in main. Request the rate (accept 10-60 MPG inclusive only) and (accept 3-30 1/100km inclusive only). Continue to ask the user until the rate is within th specified range. Do this in a separate function. Do the conversion. Use imperial gallons (4.546 liters per gallon) in your calculations. Do this in a separate function, the function must be called from main. Display the result. The output should include the input rate including units and the converted rate including units. The output must be displayed with an accuracy of two decimal places. Do this in a separate function. Ask the user if he/she would like to complete another conversion. If so (accept Y or y only), do not explain the purpose of the program again. The program should continue until the user would like to quit. Do this in main
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
