Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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