I have been working on this program for over a week. I can only use loops. Please help!!
I need this program to go through 3 sales people Reid, Nicole, and Jarid. Then allow the user to enter up to 4 sales amounts. I need the program to continue until the user enters Z. Then, the output should be the total sales for each sales person along with their commission which is .13 of sales. Here is what I have so far.
Would you like to elaborate by what you mean by 3 sales people?
at line 30 add for(int x = 0; x < 3; x++){
to make it look 3 times at what I think you mean by loop three times,
you also have an extra } at line 88, although if you add what I said, it uses that extra }
Joshhua5... Thanks for the tip.. what I need this program to do is to create a report that tracks the sales of 3 sales people. – Reid, Jarid, and Nicole. I need to prompt the user for a salesperson’s initial R, J, or N... then allow the user to enter up to 4 sale amounts at a time for the salesperson. I need to calculate and display the salesperson’ s commission as 13% of the sales entered. Add the commission to a running total for that salesperson. The program should terminate when the user types a ‘Z’. A final report should display each salesperson’s total commission earned along with their average sales.
I know this is very basic however I am struggling with a few concepts. any tips would be greatly appreciated...
You need to extend your 4 loop where you ask for sales details to also include the math performed after the loop, otherwise only the last sale will be recorded.
Thanks! I just did that. Now I am struggling with the sales being added to the appropriate sales person. The way I have it, the sales all get added to all 3 sales people. I appreciate the tips!
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
usingnamespace std;
int main()
{
constchar Reid[] = "Reid";
constchar Jarid[] = "Jarid";
constchar Nicole[] = "Nicole";
constchar *name;
char input;
int number,
sales,
salesReid = 0, // counter
salesJarid = 0,
salesNicole = 0,
totalReid = 0,
totalJarid = 0,
totalNicole = 0;
//set format for dollar values
cout << fixed << showpoint << setprecision(2);
//Get user to select Salesperson
// need some type of loop here to continue until user enters "Z"
for(int x = 0; x < 3; x++){ //this is only going to loop through 3 times...
cout << "To enter sales for Reid, enter R.\n"
<< "To enter sales for Jarid, enter J.\n"
<< "To enter sales for Nicole, enter N.\n"
<< "Enter your choice: ";
cin >> input;
if( input == 'R')
{
cout << "How many sales amounts will you enter (Maximum is 4): ";
cin >> number;
// input validation number of sales entered
if ((number <= 0) || (number > 4))
{
cout << "Number is invalid may not be less than 1 or more "
<< "than 4.\n"
<< "Enter number of sales to be entered: ";
cin >> number;
}
for (int count = 1; count <= number; count++)
{
cout << "Enter the amount for sale " << count << ": ";
cin >> salesReid;
}
if (input == 'J')
{
cout << "How many sales amounts will you enter (Maximum is 4): ";
cin >> number;
// input validation number of sales entered
if ((number <= 0) || (number > 4))
{
cout << "Number is invalid may not be less than 1 or more "
<< "than 4.\n"
<< "Enter number of sales to be entered: ";
cin >> number;
}
for (int count = 1; count <= number; count++)
{
cout << "Enter the amount for sale " << count << ": ";
cin >> salesJarid;
}
if (input == 'N')
{
cout << "How many sales amounts will you enter (Maximum is 4): ";
cin >> number;
// input validation number of sales entered
if ((number <= 0) || (number > 4))
{
cout << "Number is invalid may not be less than 1 or more "
<< "than 4.\n"
<< "Enter number of sales to be entered: ";
cin >> number;
}
for (int count = 1; count <= number; count++)
{
cout << "Enter the amount for sale " << count << ": ";
cin >> salesNicole;
}
/*if(name == Reid )
{
sales == salesReid;
}
else if (name == Jarid)
{
sales == salesJarid;
}
else if (name == Nicole)
{
sales == salesNicole;
}
*/
// input validation for name
/*while (!(name == Reid || name == Jarid || name == Nicole));
{
cout << "Enter the first letter of your first name in caps: ";
cin >> input;
}
int sales;
if(name == Reid )
{
sales = salesReid;
}
else if (name == Jarid)
{
sales = salesJarid;
}
else if (name == Nicole)
{
sales = salesNicole;
}
*/
/*cout << "How many sales amounts will you enter (Maximum is 4): ";
cin >> number;
// input validation number of sales entered
if ((number <= 0) || (number > 4))
{
cout << "Number is invalid may not be less than 1 or more "
<< "than 4.\n"
<< "Enter number of sales to be entered: ";
cin >> number;
}
for (int count = 1; count <= number; count++)
{
cout << "Enter the amount for sale " << count << ": ";
cin >> sales;
*/
// Here the totals are stored
//sales += sales;
salesReid += salesReid;
//totalReid += salesReid;
//totalReid = salesReid + salesReid;
//salesJarid += sales;
//sales += salesNicole;
//salesReid += sales; //accumulate running total
//totalNicole += sales;
//totalJarid += sales;
}
}
double commission = sales * .13;
cout << "Commission earned for sales entered is: " << commission << endl;
cout << "Total sales for Reid are: " << sales << endl;
cout << "Total sales for Nicole are: " << salesReid << endl;
cout << "Total sales for Jarid are: " << totalReid << endl;
//outputFile << commission << endl;
//outputFile << totalReid << endl;
}
system ("pause");
}
return 0;
}