Question: C++ The following program is to determine the minimum sales and the person with the least sale based on the number of input the user

C++
The following program is to determine the minimum sales and the person with the least sale based on the number of input the user has. Do the following :
Convert the loop from for loop to while loop. The user can continue the program as long as they have data
There are syntax errors in the program which makes the output incorrect. Correct the program to get the correct output (minimum sales and the person with the least sale).
Add instructions to calculate the average of all sales and display the average calculated.
#include
using namespace std;
int main()
{
int sales;
string salesman, leastSale;
int average, total = 0;
int count = 0;
int min = 0;
cout << "How many data do you have ? ";
cin >> count;
for (int i = 1; i <= count; i++)
{
cout << "Enter sales : $ " ;
cin >> sales;
cout << "Enter the Salesman : ";
cin >> salesman;
if (sales < min)
{
sales = min;
leastSale = salesman; //save the name
}
} //end of loop
cout << " Minimum sales: $ "<< sales;
cout << " Person who made least sale : " << salesman;
return 0;
}

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!