Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions

Question

Understand digital transmission of analog data

Answered: 1 week ago

Question

Decision Making in Groups Leadership in Meetings

Answered: 1 week ago