63 066
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #21325 in C++ for suahil akbar

Question #21325
Write a program that prompts the user to input an integer between 0 and 25. If user enters 0 then Display A, if user enters 1 then Display B, if user enter 2 then Display C and so On... Otherwise Display Invalid Number and Prompt for Character to Start Again/Exit. Don‟t use more than 5 if else statements otherwise you will get 0 marks.?
Expert's answer
// Defines the entry point for the console application.

#include "iostream"

using namespace std;

int main(int argc, _TCHAR* argv[])
{
int variable;
int selector = 1;

while(selector)
{
cout<<"Enter your choise:"<<endl;
cin>>variable;
switch (variable)
{
case 0:
cout<<"A"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 1:
cout<<"B"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 2:
cout<<"C"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 3:
cout<<"D"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 4:
cout<<"E"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 5:
cout<<"F"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 6:
cout<<"G"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 7:
cout<<"H"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 8:
cout<<"I"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 9:
cout<<"J"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 10:
cout<<"K"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 11:
cout<<"L"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 12:
cout<<"M"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 13:
cout<<"N"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 14:
cout<<"O"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 15:
cout<<"P"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 16:
cout<<"Q"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 17:
cout<<"R"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 18:
cout<<"S"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 19:
cout<<"T"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 20:
cout<<"U"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 21:
cout<<"V"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 22:
cout<<"W"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 23:
cout<<"X"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 24:
cout<<"Y"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

case 25:
cout<<"Z"<<endl;
cout<<"Continue( press 1 ) or exit( press 0 ) ?"<<endl;
cin>>selector;
break;

default:
cout<<"Error code"<<endl;
}
}
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions