Question: I have a c++ Project I need help with, please note that we have not gone into arrays or the advanced stuff. Here are the

I have a c++ Project I need help with, please note that we have not gone into arrays or the advanced stuff.

Here are the instructions:

This project uses nested loops. - the outer loop processes vegetable categories - the inner loop processes seasons within a vegetable category. There are the same number of seasons for each vegetable category.

Your program will use nested loops, as seen in the sample run given below.

For a particular vegetable category in the outer loop, the inner loop will process all seasons, one by one. - Input the number of seeds, the number of plants and the unit price of a plant. - Keep a running total of: - the growing ratio of plants to seeds - the total selling price of all plants At the end of the inner loop report the growing ratio and total selling price for that category

After all categories have been processed, report the following: - The category of the best growing group (having the highest ratio) - The category of the best selling price (having the largest sales)

Sample Run - note all user input data ( cin >> ) is shown in red

Use of the setw(... ) and the setpresion(... ) will customize the program output. Read the ioManip.cpp in the "Instructor's Sample Program" in Lesson 2.

/* Enter the number of the veg catagory : 2 Enter the number of the seasons : 2 ---------------------------------------------------------- catagory 1 : season 1 : Enter Number of Seeds : 13 Enter Number of Plants : 11 Enter UnitPrice : 1.2 season 2 : Enter Number of Seeds : 14 Enter Number of Plants : 10 Enter UnitPrice : 2.1 growing ratio for catagory 1 : 78.02% total sold price for catagory 1 : 34.20 ---------------------------------------------------------- catagory 2 : season 1 : Enter Number of Seeds : 12 Enter Number of Plants : 11 Enter UnitPrice : 1.1 season 2 : Enter Number of Seeds : 14 Enter Number of Plants : 12 Enter UnitPrice : 1.4 growing ratio for catagory 2 : 88.69% total sold price for catagory 2 : 28.90 ---------------------------------------------------------- ---------------------------------------------------------- The best growing group is Catagory 2, with the best growing ratio : 88.69% The best total selling price is Catagory 1, with the price : 34.20 Press any key to continue . . . */

Here is my sample code:

#include

#include

using namespace std;

int main()

{

int num_of_veg_categories, num_of_seasons, seeds, plants, total_seeds, total_plants;

double unit_price, ratio_perc, total_price;

double bestRatio = 0; // ***set up for Ratio comparison

double bestAmount = 0; // ***set up for total sold price comparison

total_seeds=0;

total_plants=0;

total_price=0;

cout << setprecision(2) << fixed;

cout << "Enter the number of veg category: ";

cin >> num_of_veg_categories;

cout << "Enter the number of seasons: ";

cin >> num_of_seasons;

for (int i=1; i<=num_of_veg_categories; i++) //*****Errors

{

cout << "Category" << i << ":" << endl;

for (int j=1; j<=num_of_seasons; j++)

{

cout << "Season" << j << ":" << endl;

cout << "Enter the number of seeds: ";

cin >> seeds;

cout << "Enter the number of plants: ";

cin >> plants;

cout << "Enter the unit price: ";

cin >> unit_price;

total_seeds+=seeds;

total_plants+=plants;

total_price+= plants*unit_price;

}// ***seasons

ratio_perc= ( (double) total_plants / total_seeds) / num_of_seasons*100;

if(ratio_perc > bestRatio)

{

bestRatio = ratio_perc;

......

}

if(total_price > bestAmount)

{

bestAmount = total_price;

.....

}

} //***outer loop

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!