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

For this assignment you will be required to write a C++ program which accepts a

ID: 3688794 • Letter: F

Question

For this assignment you will be required to write a C++ program which accepts a text file containing information about a series of hits to various websites. Your program will then store this information and will provide the user with a menu that will look up information about a website of his or her choosing.

Here is the format for the input file:

(IP_Address) (Link_Name) (Date_Accessed)

IP_Address is the IP Address of the user which does not contain any spaces.

Link_Name is the name of a website that does not contain any spaces (maximum 50 characters).

Date_Accessed is the date of the hit in mm/dd/yyyy format (Ex: 07/06/2016)

Each hit has its information on its own line in the input file.

Entries for hits in the data file which contain invalid data (such as an invalid date, etc.) should be reported to the user with an error message.
The entire entry for that hit should then be ignored.

Your program should provide a menu with the following items:

1) Report information about hits for a given link in a period of time:
Asks the user for a link to a website and a starting date and ending date, each in mm/dd/yyyy form
For the given input, your program must search through the list of hits and report the following information about the link by considering only the hit entries in the given time period:
- the number of total hits (times that the link was listed altogether)
- the number of hits by unique visitors (the number of visitors who visited the link, not counting duplicate visits)
- the number of hits by returning visitors (number of visits beyond the first by visitors)
NOTE: The sum of the unique visitor hits and repeating visitor hits should equal the total hits. Thus, it is not necessary to search the list a third time for the returning visitor hits if you already know the total hits and unique visitor hits.
If the user inputs any invalid information (non-existent date, start date comes after end date, or a link that was not in the input file) an error message should be displayed and you should then prompt the user to re-enter the data.

2) Print the input information from the text file based upon number of unique visitors to each website (in increasing order)

3) Quit the program

Optional Extra Credit: Include an additional menu option which prompts the user for a link and creates a bar chart for the past twelve months of hits in each month. Each month must fit on one page, so if there are too many hits for a given month you must change the number of hits each star represents.

Your program should also follow the following requirements:

You must prompt the user for the name of the input file, which the user will then enter by using the keyboard

Your program must be written in C++ to receive any credit.

You must use at least one class in addition to the main program

Your output should be printed in a neatly formatted table (see SAMPLE OUTPUT below)

You may use any sorting algorithm you wish to perform the sorting operation, including any algorithms listed in textbooks.

If there is an error reading from the file or if any input data is invalid you should inform the user of the situation.
In the event that the input data is invalid, you must ingore the record and print along with your error message the name of the owner of the invalid account.

Your program should make good use of functions and be well commented

You must include a "makefile" which correctly compiles your multiple source files

SAMPLE INPUT AND OUTPUT

Note that the input file is in black, commnets are in green and the output follows in blue:

Explanation / Answer

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

using namespace std;

int main()
{
std::ifstream readfile("data.txt");//reding numbers from text file
std::string eachline;
int count=0;
string links[50];
string names[50];
string dates[50];

while (std::getline(readfile, eachline))
{
   std::istringstream iss(eachline);
   int link,name,date;   
   while (iss >> link,name,date)//reading each value from file
   {
       if(date.length() != 10){
           cout<<" Error in parsing date";
       }
       //storing data into arrays
       links[count] = link;
       names[count] = name;
       dates[count] = date;
       count++;
   }
}

//priting menu
while(true){
   cout<<"Please select a menu option: 1)Link Information in date range 2)Information about all links 3)Quit the program";
   int choice;
   //reading choice from user
   cin>>choice;
   if(choice == 1){
       //reading link and start, end dates from user
       cout<<" Enter a link name: ";
       string link,date1,date2;
       cin>>link;
       cout<<"Enter a start date: ";
       cin>>date1;
       cout<<"Enter a end date: ";
       cin>>date2;
       int unique=0,totalHits=0;
       for(int i=0;i<count;i++){
           int originalDate = atoi(dates[i]);
           int first = atoi(date1);
           int second = atoi(date2);
           //cheking for link with given inputs
           if(names[i] == link && first>=originalDate && second<=originalDate){
               totalHits++;
           }
           if(names[i] == link && dates[i] == date1){
               unique++;
           }
       }
       //printing results
       cout<<" Link: "<<link;
       cout<<" Total hits: "<<totalHits;
       cout<<" Unique: "<<unique;
       cout<<" Returning: "<<(totalHits - unique);
   }
   else if(choice == 2){
       //prinitng file data
       for(int i=0;i<count;i++){
           cout<<" "<<links[i]<<" "<<names[i]<<" "<<dates[i];
       }
   }
   else{
       //exiting
       break;
   }
}

return 0;
}

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