Question: For my C++ lab i have to create a program to use If statements and loops. ive attached the procedure down below as well as
For my C++ lab i have to create a program to use If statements and loops. ive attached the procedure down below as well as the code ive made so far. im working on this in visual studio if that makes a diffrence and only includes that can be used are the ones ive placed in my code. there is an error in my code for my 'type' term as i havent initalized it, im having trouble understanding what that means.
the code:
#include
#define _CRT_SECURE_NO_WARNINGS /******************************************************************************* LAB 4: If statements ******************************************************************************** Developed by: Date: Jan 31, 2020 ******************************************************************************** Description: Using if statements *******************************************************************************/
/******************************************************************************* Main *******************************************************************************/ void purpose(); float getNumber(float);
void main() { //Variable Declarations/user inputs purpose(); //print the message char type; // for metric or imperial (MPG or 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); } else { if (type == 'M' || type == 'm') { printf(" you have chosen to convert L/100km to MPG "); fflush(stdin); }
if (type != 'm' || type != 'M' || type != 'l' || type != 'L') { 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 ");
} 

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
