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

Re-write your program for HW3 (list of chores problem 5 in chapter 4) using a un

ID: 3800438 • Letter: R

Question

Re-write your program for HW3 (list of chores problem 5 in chapter 4) using a unique_ptr object as your data member. You should store a dynamic array in the unique_ptr object. Use this array for storing, retrieving, deleting and updating chores.

Here's the proigram i wrote. can i get help on adding whats above. its in C++

#include
#include
#include
#include
using namespace std;
int main()
{
std::vector chores; // Vector to hold our words we read in.
std::string str; // Temp string to

std::ifstream fin("chores.txt"); // Open it up!
while (fin >> str) // Will read up to eof() and stop at every
{                  // whitespace it hits. (like spaces!)
    chores.push_back(str);
}
fin.close(); // Close that file!

   
   int c;
   while(c!=5)
   {
       cout<<" 1:Add an item to list of chores 2:Ask how many chores are in list 3:Have the list of chore printed to Screen 4:Delete an item from the list 5:Exit Enter you choice:";
       cin>>c;
       if(c==1)
       {string s;
       cout<<"Enter item you want to Add:";cin>>s;//taking user input
       chores.push_back(s);//adding item ..to list
       }
       else if(c==2)
       {
           cout<<"Total number of chores:"<        }
       else if(c==3)
       {
           cout<<"Items are: ";
           for (int i = 0; i < chores.size(); ++i)
            std::cout << chores.at(i) << std::endl; // printing items
       }
       else if(c==4)
       {
           string s;
           cout<<"Enter item name you want to delete:";cin>>s;//taking user input.
           for (int i = 0; i < chores.size(); ++i)
           {
                   if(s.compare(chores.at(i))==0)//finding approriate item to delete
                   {
                       //erasing from list..
                       chores.erase(chores.begin()+i);cout<<"item removed ";break;  
                   }
           }  
       }
      
       ofstream OFileObject; // Create Object of Ofstream
    OFileObject.open ("chores.txt"); // Opening a File
    for (int i = 0; i < chores.size(); ++i)//writing to files..
   {OFileObject<<chores[i]<<" ";}
    OFileObject.close(); // Closing the file      
          
   }
   
   
   
   

return 0;
}

Write a program that uses a dynamic list of strings to keep track of a list of chores that you have to accomplish today. The user of the program can request several services: (1) Add an item to the list of chores; (2) Ask how many chores are in the list; (3) Have the list of chores printed to the screen; (4) Delete an item from the list; (5) Exit the program If you know how to read and write strings from a file, then have the program obtain its initial list of chores from a file. When the program ends, it should write all unfinished chores back to this file.

Explanation / Answer

using namespace std;
int main()
{
std::vector chores; // Vector to hold our words we read in.
std::string str; // Temp string to

std::ifstream fin("chores.txt"); // Open it up!
while (fin >> str) // Will read up to eof() and stop at every
{                  // whitespace it hits. (like spaces!)
    chores.push_back(str);
}
fin.close(); // Close that file!

   
   int c;
   while(c!=5)
   {
       cout<<" 1:Add an item to list of chores 2:Ask how many chores are in list 3:Have the list of chore printed to Screen 4:Delete an item from the list 5:Exit Enter you choice:";
       cin>>c;
       if(c==1)
       {string s;
       cout<<"Enter item you want to Add:";cin>>s;//taking user input
       chores.push_back(s);//adding item ..to list
       }
       else if(c==2)
       {
           cout<<"Total number of chores:"<        }
       else if(c==3)
       {
           cout<<"Items are: ";
           for (int i = 0; i < chores.size(); ++i)
            std::cout << chores.at(i) << std::endl; // printing items
       }
       else if(c==4)
       {
           string s;
           cout<<"Enter item name you want to delete:";cin>>s;//taking user input.
           for (int i = 0; i < chores.size(); ++i)
           {
                   if(s.compare(chores.at(i))==0)//finding approriate item to delete
                   {
                       //erasing from list..
                       chores.erase(chores.begin()+i);cout<<"item removed ";break;  
                   }
           }  
       }
      
       ofstream OFileObject; // Create Object of Ofstream
    OFileObject.open ("chores.txt"); // Opening a File
    for (int i = 0; i < chores.size(); ++i)//writing to files..
   {OFileObject<<chores[i]<<" ";}
    OFileObject.close(); // Closing the file      
          
   }
   
   
   
   

return 0;
}