Description: Friend’s finder. You load a data file first. Then you answer 10 questions. The answers will be saved in an array. The data in file are several arrays answered by other users. You need to compare the answers with other users and calculate the similarity. After that it will show your best 1Emphasized Text Here0 matches on the monitor.
I am able to read the file but I am having major issues with assigning the values in the file into several arrays. Every time I run the program it fails it may be a loop problem but I'm not completely sure.
This is my data file: Answers2.txt
Howard Lacrosse 19 Engineering LTU Belleville Green Pizza African Male
Zaid Tennis 19 Engineering LTU Dearborn Pink Soup Arab Male
Yat Basketball 19 Civil LTU Belleville Green Rice Chinese Male
Stephanie Yoga 24 Architect Central southfield Blue Chicken Asian Female
Adam Soccer 19 GameArt LTU Ypsilanti Red Chicken Caucasian Male
Ashley Karate 18 Media LTU Westland Magenta Oranges Caucasian Female
Hentrell Basketball 19 GameArt LTU Chicago Black Chicken African Male
Corey Baseball 24 PreDental LTU Chicago Black Pizza Caucasian Male
Topanga Golf 25 Physics LTU Dearborn Pink Soup Caucasian Female
Katelyn Softball 20 History GrandValley Warren Blue Oranges Caucasian Female
The 10 questions if you cannot tell:
What is the person's name?
What is their favorite Sport?
How old is said person?
What Major is said person?
What School does said person attend?
Where is said person From?
What is said person's favorite color?
What is said person's favorite food?
What race is said person?
What sex is said person
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstdlib>
using namespace std;
void outputLine(string [], string [], int [], string [], string [], string [], string [], string [], string [], string []);
int main()
{
ifstream inClientFile("Answers2.txt", ios::in);
if(!inClientFile)
{
cerr <<"FIle could not be opened" <<endl;
exit(1);
}
string name[9];
string sports[9];
int age[9];
string major[9];
string school[9];
string city[9];
string color[9];
string food[9];
string race[9];
string sex[9];
for(int i = 0; i <= 9; i++)
{
inClientFile >> name[i] >> sports[i] >> age[i] >> major[i] >> school[i] >> city[i] >> color[i] >> food[i] >> race[i] >> sex[i];
outputLine(name, sports, age, major, school, city, color, food, race, sex);
}
}
void outputLine(string name[9], string sports[9], int age[9], string major[9], string school[9], string city[9], string color[9], string food[9], string race[9], string sex[9])
{
cout <<left<< setw(7) << name[9] << setw(7) << sports[9] << setw(7) << age[9] << setw(7) << major[9] << setw(7) << school[9] << setw(7) << city[9] << setw(7) << color[9] << setw(7) << food[9] << setw(7) << race[9] << setw(7) << setprecision(2) << right << sex[9]<<endl;
}