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 ");
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started