uestion 1 Construct a complete C++ program from the following conditions; (Note
ID: 3891403 • Letter: U
Question
uestion 1 Construct a complete C++ program from the following conditions; (Note your code 1. should include appropriateComments); 1- User must enter "start" to start the program 2- User are able to enter any characters and floating point number. 3- If user entered character between 'a' to 'g' or number between 1 to 25.789, please display "Level 1". 4- If user entered character between 'h' to 'm' and number between 26 to 30.789, please display "Level 2" 5-If user entered other characters or other numbers, please display "Level 3"Explanation / Answer
#include<iostream>
#include<ctype.h>
using namespace std;
int main()
{ string str;
char ch;
float f;
cout<<"Enter start to start the programm"<<endl;
cin>>str;
if(str=="start")
{
cout<<"enter character and number"<<endl;
cin>>ch>>f;
if((ch>='a'&& ch<='g') ||(f>=1 && f<=25.789 ))
cout<<"level 1"<<endl;
else if((ch>='h'&& ch<='m') && (f>=26 && f<=30.789 ))
cout<<"level 2"<<endl;
else
cout<<"level 3"<<endl;
}
else
cout<<"quitting the programm"<<endl;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.