Question 1 Here is my program : include #include #include using namespace std; //Prototypes void loadArray(string[],int[],int); void updateSales(string[],int[],int); int main() { int const SIZE = 10; string plantName[SIZE]; int beginningQty[SIZE]; double plantprice[SIZE] = { 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5 }; int totalSales[SIZE] = { 0 }; loadArray(plantName, beginningQty, SIZE); updateSales(plantName, totalSales, SIZE); return 0; } //Function loadArray void loadArray(string plantName[], int beginningQty[], int SIZE) { for (int x = 0; x < SIZE; x++) { cout << "Enter the plant #" << x + 1 << " name: "; getline(cin, plantName[x]); cout << "Enter the beginning quantity on hand for " << plantName[x] << ": "; cin >> beginningQty[x]; cin.ignore(); while (beginningQty[x] < 0) { cout << "Invalid quantity, must be >0"; cout << "Enter the beginning quantity on hand for " << plantName[x] << ": "; cin >> beginningQty[x]; } } return; } void updateSales(string plantName[],int totalSales[], const int SIZE) { string name; int sold; cout << "Enter the name of the plant to update sales: "; getline(cin, name); for (int i = 0; i < SIZE; i++) { if (plantName[i] == name) { do { cout << "Enter the number of " << name << " sold: "; cin >> sold; if (sold < 0) { cout << "Invalid number, please enter a non-negative number.\n"; } } while (sold < 0); totalSales[i] += sold; cout << "Sales of " << name << " updated to " << totalSales[i] << ".\n"; return; } } cout << "Plant " << name << " not found.\n"; return; } Can you help me to write a function to sort the arrays by the plants sold. This function does not print anything. Remember to indent where appropriate. Full explainthe this question very fast solution sent me step by step Don't ignore any part all part work u Text typing work only not allow paper work
Question 1
Here is my program :
include<iostream>
#include<string>
#include<cctype>
using namespace std;
//Prototypes
void loadArray(string[],int[],int);
void updateSales(string[],int[],int);
int main()
{
int const SIZE = 10;
string plantName[SIZE];
int beginningQty[SIZE];
double plantprice[SIZE] = { 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5 };
int totalSales[SIZE] = { 0 };
loadArray(plantName, beginningQty, SIZE);
updateSales(plantName, totalSales, SIZE);
return 0;
}
//Function loadArray
void loadArray(string plantName[], int beginningQty[], int SIZE)
{
for (int x = 0; x < SIZE; x++)
{
cout << "Enter the plant #" << x + 1 << " name: ";
getline(cin, plantName[x]);
cout << "Enter the beginning quantity on hand for " << plantName[x] << ": ";
cin >> beginningQty[x];
cin.ignore();
while (beginningQty[x] < 0)
{
cout << "Invalid quantity, must be >0";
cout << "Enter the beginning quantity on hand for " << plantName[x] << ": ";
cin >> beginningQty[x];
}
}
return;
}
void updateSales(string plantName[],int totalSales[], const int SIZE)
{
string name;
int sold;
cout << "Enter the name of the plant to update sales: ";
getline(cin, name);
for (int i = 0; i < SIZE; i++)
{
if (plantName[i] == name) {
do {
cout << "Enter the number of " << name << " sold: ";
cin >> sold;
if (sold < 0) {
cout << "Invalid number, please enter a non-negative number.\n";
}
} while (sold < 0);
totalSales[i] += sold;
cout << "Sales of " << name << " updated to " << totalSales[i] << ".\n";
return;
}
}
cout << "Plant " << name << " not found.\n";
return;
}
Can you help me to write a function to sort the arrays by the plants sold. This function does not print anything.
Remember to indent where appropriate.
Full explainthe this question very fast solution sent me step by step
Don't ignore any part all part work u
Text typing work only not allow paper work
Step by step
Solved in 5 steps with 3 images