I am very confused as to how to go about this c++ assignment. I know I need to use fstream but am completely stuck.
"Modify your code to enter the favorite beverage of each person and
store it in a text file “survey.txt”, after finishing the data entry, close the file and then process the data from the file to produce the output similar to Lab #3."
Note:
1. When you run the program it will ask you if you want to enter the favorite
beverages or not.
2. If there is no file or no data in the file it will display a message to ask you if
you want to enter the data or quit the program
cout << "Please input the favorite beverage of person #:" << counter + 1 << "\n";
cout << "Choose 1, 2, 3 or 4 from the above menu or -1 to exit the program: ";
if (choice == 1)
{
coffee++;
}
else if (choice == 2)
{
tea++;
}
else if (choice == 3)
{
coke++;
}
else if (choice == 4)
{
oj++;
}
else
{
cout << "invalid selection" << endl;
}
counter++;
}
cout << "The total number of people surveyed is " << counter << "The results are as follows: Beverage Number of Votes\n";