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

Your Community Supported Agriculture (CSA) farm delivers a box of fresh fruits a

ID: 3771708 • Letter: Y

Question

Your Community Supported Agriculture (CSA) farm delivers a box of fresh fruits and vegetables to your house once a week. For this Programming Project, define the class BoxOfProduce that contains exactly three bundles of fruits or vegetables. You can represent the fruits or vegetables as an array of type string . Add accessor and mutator functions to get or set the fruits or vegetables stored in the array. Also write an output function that displays the complete contents of the box on the console.

Next, write a main function that creates a BoxOfProduce with three items randomly selected from this list:

Broccoli

Tomato

Kiwi

Kale

Tomatillo

This list should be stored in a text file that is read in by your program. For now you can assume that the list contains exactly five types of fruits or vegetables.

Do not worry if your program randomly selects duplicate produce for the three items. Next, the main function should display the contents of the box and allow the user to substitute any one of the five possible fruits or vegetables for any of the fruits or vegetables selected for the box. After the user is done with substitutions output the final contents of the box to be delivered. (PS: c++ program and change array to vector!! Thank you very much!)

Explanation / Answer

#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;

class BoxOfItem
{
public:
  
      BoxOfItem();
      void displayWord(int box);
      void input();
      void output();
      string Box11[];  
private:
  
      string list[5];
      static int cnt;
  
};
   int BoxOfItem::cnt=0;
        BoxOfItem::BoxOfItem()
{
   list[0]= {"Broccoli"};
   list[1]= {"Tomato"};
   list[2]= {"Kiwi"};
   list[3]= {"Kale"};
   list[4]= {"Tomatillo"};
}

void BoxOfItem::input()
   {
      
   }    
void BoxOfItem::output()
{
   int i11;
   cout<<"In your bundle: ";
   for( i11=0; i11 < 3; i11++)
   {
       srand(time(0));
      int box = rand()% 5;
                Box11[i11] = list[box];
       displayWord( box);
   }
}
void BoxOfItem::displayWord(int box)
{
   cout << Box11[box]<<endl;
}
int main()      
{
  
   BoxOfItem b11;
   b11.input();
   b11.output();
}
const string Brocc = "Broccoli";
const string Toma = "Tomato";
const string Kwi = "Kiwi";
const string Kale = "Kale";
const string Tili = "Tomatillo";

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