Question

When the user has finished entering the sales amounts, the program should display the number of...

When the user has finished entering the sales amounts, the program should display the number of sales amount entered and the average commission.

#include <iostream>
using namespace std;

int main() {

const double rate =0.2;
int sales = 0;
double commission = 0.0;
double totalSales =0.0;

cout << "First salesperson's sales (-1 to stop) : ";
cin >> sales;
while (sales !=-1)
{
commission = sales * rate;

cout << "Commission : $ " << commission << endl;
cout << "Next salesperson's sales (-1 to stop) : ";
cin >> sales;

}
  
   return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
using namespace std;

int main() {

const double rate =0.2;
double sales = 0;
int count=0;
double commission = 0.0;
double totalSales =0.0;

cout << "First salesperson's sales (-1 to stop) : ";
cin >> sales;
while (sales !=-1)
{
   count++;
   commission+=sales*rate;
   cout << "Next salesperson's sales (-1 to stop) : ";
   cin >> sales;
}
cout<<"Number of sales amount entered : "<<count<<endl;
cout << "Average Commission : $ " << commission/count << endl;
return 0;
}

// If any doubt please comment

Add a comment
Know the answer?
Add Answer to:
When the user has finished entering the sales amounts, the program should display the number of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Have Corporate Sales for 6 divisions and their quarterly sales figures. The issue is the error...

    Have Corporate Sales for 6 divisions and their quarterly sales figures. The issue is the error function where I am unable to have user reinput the same quarterly amount without going to the next quarter input. This has affected the total sales for the company. /***************************************** This program gathers sales information for six divisions and displays the total sales for each division and total company. *****************************************/ #include<iostream> using namespace std; // Classs division sales class DivSales { private: // Variables...

  • Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score (display the student’s name and score). Also calculate the average score and indicate by how

    This is what I have as of right now. I am lost on what to do next#include <stdio.h>#include <iostream>using namespace std;int main(){    double scores, numOfStudents, average = 0, highscore, sum = 0;    string names;    cout << "Hello, please enter the number of students" << endl;    cin >> numOfStudents;    do {        cout << "Please enter the student's name:\n";        cin >> names;        cout << "Please enter the student's...

  • Consider the following program in which the statements are in the incorrect order. Rearrange the statements...

    Consider the following program in which the statements are in the incorrect order. Rearrange the statements so that the program prompts the user to input the height and the radius of the base of a cylinder and outputs the volume and surface area of the cylinder. Formant the output to two decimal places. #include <iomanip> #include <cmath> int main () {} double height; cout << ”Volume of the cylinder = “ <<PI * pow(radius, 2.0) * height << endl; cout...

  • working on a program in c++ The user enters an email address into your program. You...

    working on a program in c++ The user enters an email address into your program. You must cuteverything after the @ symbol and output it. #include <iostream> #include <string> using namespace std; int main() { string email_adress = ""; //email get the info cout <<"what is your email adress? "; getline(cin, email_adress) ; cin.ignore('@'); // now we put into writitng in sentence cout <<"the email you entered is: " << email_adress << ". " <<"your email adress domian is :"...

  • Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout...

    Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;

  • Need to revise the following code to use an array of product objects instead of two...

    Need to revise the following code to use an array of product objects instead of two parallel arrays. The product class will need member variables to hold a product name and a quantity. #include<iostream> #include<string> using namespace std; int main() { //Declare variables const int salsaTypes = 5; const int jarsSold = 5; string salsa[salsaTypes] = { "Mild", "Medium", "Sweet", "Hot", "Zesty" }; int jars[jarsSold]; int totalSales, highestSales, lowestSales; string highestSoldProduct; string lowesetSoldProduct; //Repeat loop for all salsas for (int...

  • what is the output for the following code? explain the steps. /*#include <iostream> using namespace std;...

    what is the output for the following code? explain the steps. /*#include <iostream> using namespace std; int f(int &i) { i = 10; return(5 * i); } int main() { int n = 5; f(n); cout << n << "\n"; return 0; } #include <iostream> using namespace std; int sub1(int n) { n--; return n; } int main() { int m = 10; for(int j = 0; j < 10; j++) m -= sub1(j); cout << m << "\n"; return...

  • Help with C++ reverse program with leading zeros. I need to put the line from the...

    Help with C++ reverse program with leading zeros. I need to put the line from the function that display the zeros in main not in the function. So how can I move the display with leading zeros in main. Thanks. Here is my code. #include <iostream> #include <cstdlib> #include <iostream> using std::cout; using std::cin; using std::endl; //function templates int reverseNum(int); int main() { //variables char buf[100]; int num; while (true) { //prompt user for input cout << "Enter the number...

  • C++ Write a function so that the main() code below can be replaced by the simpler...

    C++ Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original main(): int main() { double milesPerHour; double minutesTraveled; double hoursTraveled; double milesTraveled; cin >> milesPerHour; cin >> minutesTraveled; hoursTraveled = minutesTraveled / 60.0; milesTraveled = hoursTraveled * milesPerHour; cout << "Miles: " << milesTraveled << endl; return 0; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include <iostream> using...

  • I am having trouble figuring out what should go in the place of "number" to make...

    I am having trouble figuring out what should go in the place of "number" to make the loop stop as soon as they enter the value they put in for the "count" input. I am also having trouble nesting a do while loop into the original while loop (if that is even what I am supposed to do to get the program to keep going if the user wants to enter more numbers???) I have inserted the question below, as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT