Answer to Question #258695 in C++ for jersonjangerona

Question #258695

Make a c++ program of a simple menu program of the sample run below.


Sample Run:


Difficulty Levels

      1. - Easy

      2. - Normal

      3. - Hard

Choice : 1

 You picked Easy.

Play another game? (y/n): y

Difficulty Levels

      1. - Easy

      2. - Normal

      3. - Hard

Choice : 2

You picked Normal.

Play another game? (y/n): y

Difficulty Levels

      1. - Easy

      2. - Normal

      3. - Hard

Choice : 3

 You picked Hard.

Play another game? (y/n): y

Difficulty Levels

      1. - Easy

      2. - Normal

      3. - Hard

Choice : 4

Illegal Choice. Please try again.

Play another game? (y/n): y

Difficulty Levels

      1. - Easy

      2. - Normal

      3. - Hard

Choice : 2

You picked Normal.

Play another game? (y/n): n

Thanks for playing…

This terminates the process.

[ So, this portion the cycles repeat until expression test false,

 at which point the loop ends.]


1
Expert's answer
2021-10-30T00:38:29-0400
#include<iostream>
using namespace std;
int main()
{
	int option;
	char s;
	cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
	cout<<"\nChoice: ";
	cin>>option;
	if(option==1){
		cout<<"You picked Easy.\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
			cin>>option;
			if(option==1){
					cout<<"You picked Easy.\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
			if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
			}
			if(option==2){
		cout<<"You picked Normal.\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
		
}
 else if(option==3){


		cout<<"You picked Hard.\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
			cin>>option;
			if(option==1){
		cout<<"You picked Easy.\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
			cin>>option;
			if(option==2){
		cout<<"You picked Normal.\nPlay another game? (y/n):";
		cout<<"\nChoice: ";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
			if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
	}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
	}
	else if(option==2){
			cout<<"You picked Normal.\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
			cin>>s;
	}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}}
		else if(option==3){
			cout<<"You picked Hard.\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
			if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}	
		}
		else if(option==4){
			cout<<"Illegal Choice. Please try again\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
			if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
	}
		}
	}
	else if(option==4){
		cout<<"Illegal Choice. Please try again\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
	}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
			
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
	}
		
			}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
	else if(option==2){
		cout<<"You picked Normal.\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
	}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
}
  else if(option==3){


		cout<<"You picked Hard.\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
			cin>>s;
			if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
	}
	 else if(option==4){
		cout<<"Illegal Choice. Please try again\nPlay another game? (y/n):";
		cin>>s;
		if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
			if(s=='y'||s=='Y'){
			cout<<"\nDifficulty Levels\n1. - Easy\n2. - Normal\n3. - Hard";
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
		}
		else if(s=='n'||s=='N'){
			cout<<"Thanks for playing";
		}
	}
	
}

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS