Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For CMPSC101 Write a program to segregate attendees of a festival. The classific

ID: 3668324 • Letter: F

Question

For CMPSC101

Write a program to segregate attendees of a festival. The classification criteria is as follows: 1. Anybody below age 10 goes to room A 2. Females of ages 10 to 30 go to room B 3. Males of ages 10 to 40 go to room C 4. Females of ages 31 to 65 go to room D 5. Males of ages 41 to 65 go room E 6. Anybody above the age of 65 goes to room F

The code must perform the following actions:

Prompt the user to input Name, age and gender of a person with "Enter name, gender and age of a person " Gender can be input as F for female and M for male

Use cin to accept user input

Use if-else if -else construct to determine which room this person belongs to

Print the following after identifying room - (Name) of age (age) must go to room (room determined)

Explanation / Answer

/**C++ program that prompts the user to enter name, gender and age then finds the room number and prints
the name, gender , age and room.*/
//age.cpp
//header files
#include<iostream>
#include<string>
using namespace std;
int main()
{
   //Declaration of variables
   string name;
   char gender;
   int age;
   string room;

   //prompt for name , gender and age
   cout<<"Enter name, gender and age of a person ";
   cin>>name>>gender>>age;

   //Set room number on age and gender
   if(age<10)
       room="A2";
   else if(gender=='F' && (age>=10 && age<=30))
       room="B3";
   else if(gender=='M' && (age>=10 && age<=40))
       room="C4";
   else if(gender=='F' && (age>=31 && age<=65))
       room="D5";
   else if(gender=='M' && (age>=41 && age<=65))
       room="E6";
   else
       room="F";

   //print the name, age and gender with room
   cout<<"Name "<<name<<" of "<<age<<",gender"<<gender
       <<" goes to "<<room<<endl;


   //pause the progrma output on console
   system("pause");
   return 0;
}//end of main method

---------------------------------------------------------------------------------------------------------

Sample Output:

Enter name, gender and age of a person Micheal M 25
Name Micheal of 25,genderM goes to C4

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote