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

Write a C++ program that stimulates a questionnaire to find a roommate from your

ID: 3780314 • Letter: W

Question

Write a C++ program that stimulates a questionnaire to find a roommate from your computer class. You will ask the user various questions that might determine a suitable match, at least 5 conditions satisfied from the potential questions. Store the names of students who matches your preference in a file called matchfile. Also, store names of students who are not your preferred match in one-dimensional array called NoMatch, size 21.

a. Print the names of students from the matchfile

b. Print the total number of students interviewed

c. Print the names of students from the array NoMatch

Note: potential questions

How often do you clean?

What do you do on the weekends?

Do you like to have friends over or keep the party outside?

Do you smoke?

How often do you drink at home?

Do you have references?

What time do you go to bed?

Do you have any pets?

What is your major hobby?

write a program in C++ language with using condition statements, enum, arrays. Comment where ever applicable.

Explanation / Answer

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct Roommate
{
string roommateName;
string choices;
};
bool find ( string & studentname);
void printstudents ( void );
const int pref=5;
Room mate [ pref ] ;
int arrayIndex;
int students= 0;
int main ( )
{
ofstream SaveFile("RoommateFile.txt");
arrayIndex = 0;
roommates temp;
char choice;
string roommate;
do
{
cout << endl << endl << endl;
cout << "What would you like to do?" << endl << endl;
cout << "1. Enter your hobbies " << endl;
cout << "2. To Print the names of students from the matchfile" << endl;
cout << "3. To Print the total number of students interviewed" << endl;
cout << "4. Print the names of students from the array NoMatch" << endl
cout << "5 Exit "<< endl << endl;
cout << endl << "Enter number...." << endl;
cin >> choice;
while ( choice != '1' && choice != '2' && choice != '3' && choice != '4' choice != '5' )
{ cin >> choice; }
switch ( choice )
{
case '1':
{
cout << endl;
cout << "Enter Your Room Mate name: ";
cout << endl << "How often do you clean?" << endl;
cout << "What do you do on the weekends?" << endl;
cout << "Do you like to have friends over or keep the party outside?" << endl;
cout << "Do you smoke?" << endl;

cout << "How often do you drink at home?" << endl;

cout << "What time do you go to bed?" << endl;

cout << "Do you have any pets?" << endl;

cout << "What is your major hobby? << endl;

cin >> temp.studentName;

SaveFile << temp.studentName;

SaveFile.close();
add ( temp );
};
break;

case '2':

{

while(getline(str, mypreferences.txt))
{
while(getline(diz, Studentname.txt))
{
if((Roommates.txt && Studentname.txt)==5)
{
cout << myPreferences.txt << endl;
printstudents();

}
else
{
cout << "No prepferences matched " << endl;
}
}
}

mypreferences.close();
Studentname.close();`
}


case '3':
{
cout << "Total number of students interviewed is " << endl;
araayindex[i];
  


}
case '4':
{
cout << "Print the names of students from the array NoMatch" << endl;
  
}
while ( choice != '5' );

return 0 ;
}


void printinventory ( )
{
int i = 0;
while ( i < Studentname )
{
cout << i << ". " << Room mate[ i ].Roommatename<< " " << endl;

i++;
}
return;
}

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