Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

The year is 2021, you find yourself in an alternate dystopian sci-fi future where a major plague has sacked all corners of the globe leading to massive sickness, mandatory isolation, and Orwellian...

1 answer below »

The year is 2021, you find yourself in an alternate dystopian sci-fi future where a major plague has sacked all corners of the globe leading to massive sickness, mandatory isolation, and Orwellian levels of social control and surveillance. Climate change has lead to mass crop failure and starvation, and economic hardships threaten political alliances across the globe.

You are friends with a humble farmer who believes that the only way to save the earth is to grow enough food to keep everyone from starving. Because so many people are sick, the farmer has no one left to work the fields, but they have an idea to save their crop. They are going to use sophisticated robots and record keeping to make sure the crops yield and the world is fed.

They have tasked you with writing a computer program to keep track of the farm’s progress.

The program monitors a plot of land consisting of 5 rows and 10 columns. Each square of the farm can grow rice, beans, or potatoes. The robot that manages the farm will be represented in your program by a set of functions that can be performed on an array of characters that represent the state of the farm.

All lowercase characters represent plants that have been planted but that are not yet ready to be picked. All uppercase characters represent plants that are ripe and ready to be picked.

Here are the character representations of the different crops:

0 – empty plot of soil
X – spoiled crop (was not picked in time)

p – potato (not ready) b – bean (not ready) r – rice (not ready)

P – potato (ready) B – bean (ready) R – rice (ready)

The robot consists of the following functions:

void plant(char, int, int,char[][10]) – plants a crop at a particular location, but only if there is no plant in that location.

char harvest(int, int,char[][10]) – picks a plant at a particular location. The character of the plant is returned and at that location on the farm a ‘0’ is placed. If there is no plant at that location a ‘0’ is returned. A spoiled crop (‘X’) counts as a plant.

void wait(char[][10]) – the robot does nothing and lets time pass. Every crop in the array that is lowercase becomes uppercase. Every crop in the array that is uppercase becomes an ‘X’

string report(char[][10]) – the robot should survey the farm and generate a string that represents the farm. Each plant should be represented by its character separated by a comma and each new row should be separated by a newline character (‘\n’)

int main() - a two-dimensional character array that represents the farm should be initialized to all zeros. The robot should plant an assortment of crops throughout the field. They can be any age and any kind of plant. You should test each of your functions using the farm plot that you have generated. Any crop that is successfully harvested should be added to a vector named ‘harvest’ and any crop that you harvest that is over ripe or under ripe should be added to another vector named ‘waste’. At the end of your program print out the contents of harvest and waste along with a count of how many of each crop were harvested or wasted. Make sure you keep your code. We will be using it for the next lab.

Answered Same Day Dec 08, 2021

Solution

Bikram answered on Dec 08 2021
109 Votes
Screen Shots
1. Main Menu
2. Menu Option 1: insert plant to (0, 0) and (0, 1) position in the grid.
3. Menu Option 2: Print the plot
4. Menu Option 3: Wait for the plant to grow
5. Menu Option 2: Print the plot
6. Menu Option 3: Wait for the plant to grow
7. Menu Option 2: Print the plot
8....
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here