64 713
Assignments Done
99,4%
Successfully Done
In September 2018

Answer to Question #45442 in C++ for mehdi

Question #45442
flowcharts:
draw down the flowchart that represents the following simple game
_user will choose either level one or level two
_level one will let the user try to insert 5 even number to pass for level two
_level two ask the user to enter 10 odd number to win
_the user will always has the chance to make up to two mistakes in any level
_if he/she did a mistake in any level he/she should re-enter another value instead of the wrong one
Expert's answer
#include <iostream>
using namespace std;
 
voidLevel_1();
voidLevel_2();
int main()
{
cout<<"Select the level(1 or 2):"<<endl;
int iLevel=0;
cin>>iLevel;
 
while(1)
{
  if(iLevel==1 ||iLevel==0)
  {
Level_1();
  }
 
  if(iLevel==2)
  {
Level_2();
  }
 
  cout<<"Tocontinue, enter the: y/Y"<<endl;
  char qCh;
  cin>>qCh;
 
  if(qCh=='y' || qCh=='Y')
  {
  break;
  }
 
}
 
return 0;
}
 
void Level_1()
{
cout<<"Enter 5 evennumbers:"<<endl;
 
int num=0;
for(inti=0; i<5;)
{
  cin>>num;
  if(num%2==0)
  {
i++;
  }
  else
  {
cout<<"Wrong, try again!"<<endl;
  }
}
cout<<endl<<endl<<"===================+Congratulations,you won!+===================="<<endl<<endl;
}
 
void Level_2()
{
cout<<"Enter the 10 oddnumbers:"<<endl;

int num=0;
for(inti=0; i<10;)
{
  cin>>num;
  if(num%2==1)
  {
i++;
  }
  else
  {
cout<<"Wrong, try again!"<<endl;
  }
}
cout<<endl<<endl<<"===================+Congratulations,you won!+===================="<<endl<<endl;
}
 

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