So, here's my program, I'm currently having an issue with it, basically, the program is supposed to ask questions to users and based on a some conditions assign them an haircut. The thing is, I have to output the value of the number of users who used my program and after that end the program as soon as someone print in the first cin !yes. At the moment, all my if statement work, but the loop doesn't do what it is supposed to, also, I had to put a value in the while statement, but I would like this value to be customerOrNot=="yes".
Thanks for your help !
// This program is for Nancy's Hair salon, it assigns an hair cut to clients based on some criterias and counts the number of clients
#include<iostream> //for cout and cin
#include<string> //for string
using namespace std;
string customerOrNot, gender, name; // Defining string variables
int hero,favoriteFood, genre, number;
int main()
{
cout<<"-------------------------------------\n"<<"Welcome to Jerome's Funky Hair Salon\n"<<"-------------------------------------\n\n";// Outputing what is the program and my name
while(number<=10000)
{
cout<<"Is there a customer? (enter yes if there is and anything else to end the program)"<<endl; //Asking wether there's someone or not
cin>>customerOrNot;
if(customerOrNot=="yes") //If there's someone, the condition of some of the folowing statements will be checked
{
number++; //Adding one each time the loop is processed
cout<<endl<<"What is your name dear? "; //Prompting for the client's name
cin>>name;
cout<<"Well "<<name<<", welcome to my salon! I will ask you a few questions and your answers will determine which haircut I will give to you."<<endl;
cout<<"Please enter your choice by using the character between ( ) next to your choice"<<endl<<endl;
cout<<"Are you (m)ale or (f)emale? ";
cin>>gender;
if (gender=="f") //If gender is female, the condition of the following statements will be checked
{
cout<<"Are you a Super Hero(0) or a Super Villain(1)? ";
cin>>hero;
if(hero==1) //If she's a Super Villain, then he should get a mohawk
cout<<"\n"<<name<<", you should get a mohawk."<<"\n"<<"Hope you like it!!"<<"\n"<<"----------------------------"<<"\n";
else if (hero==0) //If he'a Super Hero, then the condition of the following statements will be checked
{
cout<<"OK "<<name<<", do you prefer Anime(0) or Sitcom(1) ? ";
cin>>genre;
if(genre==1) //If she prefers Sitcom, then she sould get a feathered
cout<<"\n"<<name<<", you should get a feathered."<<"\n"<<"Hope you like it!!"<<"\n"<<"----------------------------"<<"\n";
else if (genre==0) //If she prefers Anime, then she sould go with bangs
cout<<"\n"<<name<<", you should go with bangs."<<"\n"<<"Hope you like it!!"<<"\n"<<"----------------------------"<<"\n";
}
}
else if (gender=="m") //If gender is male, the condition of the following statement will be checked
{
cout<<"Are you a Super Hero(0) or a Super Villain(1)? ";
cin>>hero;
if(hero==1) //If he's a Super Villain, then he should get a mohawk
cout<<"\n"<<name<<", you should get a mohawk."<<"\n"<<"Hope you like it!!"<<"\n"<<"----------------------------"<<"\n";
else if(hero==0) //If he'a Super Hero, then the condition of the following statement will be checked
{
cout<<"Steak(0) or Sushi(1) ? ";
cin>>favoriteFood;
if(favoriteFood==0) //If he prefers steak over sushi, then he should get a flat top
cout<<"\n"<<name<<", you should get a flat top."<<"\n"<<"Hope you like it!!"<<"\n"<<"----------------------------"<<"\n";
else if (favoriteFood==1) //If he prefers sushi he should get a pompadour
cout<<"\n"<<name<<", you should get a pompadour."<<"\n"<<"Hope you like it!!"<<"\n"<<"----------------------------"<<"\n";
}
}
}
else if (number<5) //If the loop is processed less than 5 times, then it's a bad day
cout<<"Well that was a poor day! I had "<<number<<" customer(s) today. Tomorrow is another day..."<<endl<<"\n";
else if (number>=5) //Otherwise, if the loop is processed more than 5 times, then it's a good day
cout<<"Well that was a good day! I had "<<number<<" customer(s) today. Tomorrow is another day..."<<endl;
}
return(0);
}
Aucun commentaire:
Enregistrer un commentaire