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

Write a program in c++ that reads a file consisting of restaurant ratings and th

ID: 3578360 • Letter: W

Question

Write a program in c++ that reads a file consisting of restaurant ratings and the date the rating was submitted. It should then determine the number of ratings in each of the following ranges : 1 - 2 (Unacceptable), 3 - 4 (Poor), 5 - 6 (Average), 7 -8 (above average), 9 -10 (very good). The earliest and latest submission date of each rating range must also be shown. A sample output is :

TUSCAN GARDEN CUSTOMER RATING REPORT

Rating Total Earliest Date Latest Date

1 - 2 (Unacceptable) 2 12/10/16 12/21/16

3 - 4 (Poor) 5 12/07/16 01/18/17

5 - 6 (Average) 12 11/30/16 02/21/17

7 - 8 (above average) 29 12/11/16 03/30/17

9 -10 (very good). 17 01/20/17 03/31/17

file has these dates

Explanation / Answer

#include <iostream>
#include<fstream>
#include <string>
using namespace std;
int main()
{
int counter1 = 0;
int counter2 = 0;
int counter3 = 0;
int counter4 = 0;
int counter5 = 0;
  
string Unacceptable_Dates[1000];
string Poor_Dates[1000];
string Average_Dates[1000];
string above_average_Dates[1000];
string very_good_Dates[1000];
  
   ifstream input("data.txt");
   string date = "";
int rating = 0;
   if(input.is_open())
   {
       while(input >> rating >> date)
       {
if(rating == 1 || rating == 2)
{
Unacceptable_Dates[counter1] = date;
counter1++;
}
else if(rating == 3 || rating == 4)
{
Poor_Dates[counter2] = date;
counter2++;
}
else if(rating == 5 || rating == 6)
{
Average_Dates[counter3] = date;
counter3++;
}
else if(rating == 7 || rating == 8)
{
above_average_Dates[counter4] = date;
counter4++;
}
else if(rating == 9 || rating == 10)
{
very_good_Dates[counter5] = date;
counter5++;
}
       }
       input.close();
   }
   cout << "1 - 2 (Unacceptable)" << counter1 + 1 << Unacceptable_Dates[0] << " " << Unacceptable_Dates[counter1] << " ";
   cout << "3 - 4 (Poor)" << counter2 + 1 << Poor_Dates[0] << " " << Poor_Dates[counter2] << " ";
   cout << "5 - 6 (Average)" << counter3 + 1 << Average_Dates[0] << " " << Average_Dates[counter3] << " ";
   cout << "7 - 8 (above average)" << counter4 + 1 << above_average_Dates[0] << " " << above_average_Dates[counter4] << " ";
   cout << "9 -10 (very good)" << counter5 + 1 << very_good_Dates[0] << " " << very_good_Dates[counter5];
}

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