Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ Programming The functions are declared in the above code and I have to implement the commented code into the functions with the right loops
C++ Programming
The functions are declared in the above code and I have to implement the commented code into the functions with the right loops
332 //--- 333 // This is the main program that needs to be written 334 //---- 335 int maino 336 { 337 string row1Crop - "NA"; // Crop of the first roud 338 string row2Crop - "NA"; // Crop of the second row 339 string row3Crop "NA"; // Crop of the third row 340 string row4Crop - "NA"; // Crop of the fourth row 341 string row5Crop - "NA"; // Crop of the fifth row 342 343 float rowiCost = 0.0; // Cost of the first row 344 float row Cost = 0.0; // Cost of the second row 345 float row3Cost - 0.0; // Cost of the third row 346 float row4Cost = 0.0; // Cost of the fourth row 347 float row5Cost = 0.0; // Cost of the fifth row 348 349 string currentSeedType - "EMPTY"; // Type of the current seed 350 351 int currentRow = 0; // Current row to plant the seeds 352 int choice 0; // The user's choice 353 int numSeeds = 0; // Number of seeds per row 354 int total Harvests = 0; // Number of total harvests 355 356 float totalPrice = 0.0; // The total price of all harvests 357 float harvestPrice - 0.0; // The price of a harvest, that will be added to total price after each harvest 358 float price - 0.0; // The price of each row 359 360 bool dontLeave - true; // to tell if user wants to quit program or not 361 bool allwatered - false; // to tell if ALL crops are watered before harvesting 362 363 364 365 366 // Loop until the user is done 367 // Print the main menu to get the users choice for what they'd like to do 368 369 // If user chooses 1, we get ask how many seeds the user wants to have (make sure to reiterate what 370 // type of seed they chose) 371 // Use a loop to guarantee that the user enters a number between 1 and 21 372 373 // If user chooses 2, this is where we plant seeds. 374 // If user hasn't chosen a seed type yet, DON'T allow them to plant any seeds. Then check whether 375 // there is enough space in the garden function. 376 377 // If enough space, then ask if they want fertilizer. If yes, set price to 1.99 before 378 // calling setPrice for the row's crops, otherwise set price to 0.0 before calling setPrice 379 380 // Finally, plant the seeds! 381 382 // Display message telling them how many seeds they planted, the type of seed they planted, 383 // and how much money this row will make 384 385 // Update the row number and notice that now, not all of our crops are watered... 386 // Also, reset numSeeds and current SeedType since you do not have any seeds left 387 388 // If user chooses 3, water all crops to let them grow! If no crops to water, let user know of the error. 389 390 // If user chooses 4, harvest the crops, sell all the rows, clear the fields, reset currentRow, and update 391 // the total amount of money and harvests. User can only harvest crops if all crops are watered. 392 393 // If user chooses 5, display the garden. 394 395 // If user chooses 6, quit the program, 396 397 398 // When the user decides to quit the program, print out the total money the user earned, and number of 399 // harvests it took. 400 401 return; 402 } 332 //--- 333 // This is the main program that needs to be written 334 //---- 335 int maino 336 { 337 string row1Crop - "NA"; // Crop of the first roud 338 string row2Crop - "NA"; // Crop of the second row 339 string row3Crop "NA"; // Crop of the third row 340 string row4Crop - "NA"; // Crop of the fourth row 341 string row5Crop - "NA"; // Crop of the fifth row 342 343 float rowiCost = 0.0; // Cost of the first row 344 float row Cost = 0.0; // Cost of the second row 345 float row3Cost - 0.0; // Cost of the third row 346 float row4Cost = 0.0; // Cost of the fourth row 347 float row5Cost = 0.0; // Cost of the fifth row 348 349 string currentSeedType - "EMPTY"; // Type of the current seed 350 351 int currentRow = 0; // Current row to plant the seeds 352 int choice 0; // The user's choice 353 int numSeeds = 0; // Number of seeds per row 354 int total Harvests = 0; // Number of total harvests 355 356 float totalPrice = 0.0; // The total price of all harvests 357 float harvestPrice - 0.0; // The price of a harvest, that will be added to total price after each harvest 358 float price - 0.0; // The price of each row 359 360 bool dontLeave - true; // to tell if user wants to quit program or not 361 bool allwatered - false; // to tell if ALL crops are watered before harvesting 362 363 364 365 366 // Loop until the user is done 367 // Print the main menu to get the users choice for what they'd like to do 368 369 // If user chooses 1, we get ask how many seeds the user wants to have (make sure to reiterate what 370 // type of seed they chose) 371 // Use a loop to guarantee that the user enters a number between 1 and 21 372 373 // If user chooses 2, this is where we plant seeds. 374 // If user hasn't chosen a seed type yet, DON'T allow them to plant any seeds. Then check whether 375 // there is enough space in the garden function. 376 377 // If enough space, then ask if they want fertilizer. If yes, set price to 1.99 before 378 // calling setPrice for the row's crops, otherwise set price to 0.0 before calling setPrice 379 380 // Finally, plant the seeds! 381 382 // Display message telling them how many seeds they planted, the type of seed they planted, 383 // and how much money this row will make 384 385 // Update the row number and notice that now, not all of our crops are watered... 386 // Also, reset numSeeds and current SeedType since you do not have any seeds left 387 388 // If user chooses 3, water all crops to let them grow! If no crops to water, let user know of the error. 389 390 // If user chooses 4, harvest the crops, sell all the rows, clear the fields, reset currentRow, and update 391 // the total amount of money and harvests. User can only harvest crops if all crops are watered. 392 393 // If user chooses 5, display the garden. 394 395 // If user chooses 6, quit the program, 396 397 398 // When the user decides to quit the program, print out the total money the user earned, and number of 399 // harvests it took. 400 401 return; 402 }Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started