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

This program must read the file \"calendar.txt\" implement thefollowing function

ID: 3607965 • Letter: T

Question

This program must read the file "calendar.txt" implement thefollowing function

Search <keyword>
This function searches all of the events with the keyword andsorted by date
where <keyword> is required and denotes the keyword. Forexample,
$Search Peter //Input
2000-11-09 Peter’s birthday party.
2004-07-25 Dinner with Peter.
2007-06-30 Peter’s graduation party.
2008-12-01 Group meeting with John, Mary, Tom and Peter.

The content of the file is like follows:
2007-06-30 Peter’s graduation party.
2000-11-25 National holiday.
2008-12-12 Project meeting at 03:30PM.
2000-11-09 Peter’s birthday party.
2000-11-12 Sport hour: volley with John.
2008-12-01 Group meeting with John, Mary, Tom and Peter.
2008-12-05 Homework #3 due.
2000-11-12 Project meeting at 12:30PM.
2008-12-24 Xmas party.
2004-07-25 Dinner with Peter


Here is what I've got so far:

#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <cstring>
using namespace std;

void splitstring(string str, string seperater, string &first,string &second) //will split a string into 2
{
     int i = (int)str.find(seperater); //findseperator
     if(i != -1)
     {
          int y =0;
         if(!str.empty())
          {
              while(y != i)
              {
                   first += str[y++]; //creating first string
              }
              y = y+(int)seperater.length(); //jumping forward seperaterlength
              while(y != str.length())
              {
                   second += str[y++]; //creating second string
              }          
          }
     }
     else
     {
          first =str;
          second ="NULL"; //if seperator is not there then second string == null
     }
}


int main()
{
  
string a, b, c;
ifstream infile;
infile.open ("calendar.txt");
if (infile.is_open())
{
          cout<< "Please write the function you want to use: " <<endl;
          cout<< "(Search keyword or Quit to exit)" << endl;
          stringoption;
          getline(cin,option);
         a.assign(option);
         splitstring(a, " ", b, c);
     
          if (b =="Search")
          {
            //Here it should print the list of activities that includes theindicated keyword
            //The keyword is stored in the string c  
          }

          if(b!="Search" && b!="Quit")
          {
             cout << "[Err] Wrong command! Please read the instructionmanual." << endl;
          }
      
      infile.close();
   }

    system ("PAUSE");
    return 0;
}


Explanation / Answer

This program must read the file "calendar.txt" implement thefollowing function

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