|
 |
|
Dev Articles Community Forums
> Programming
> C/C++ Help
|
Help with array...
Discuss Help with array... in the C/C++ Help forum on Dev Articles. Help with array... C/C++ Help forum discussing building and maintaining applications in C/C++. Find out why these languages are the foundation on which other languages are built.
|
|
 |
|
|
|
|

Dev Articles Community Forums Sponsor:
|
|
|

August 10th, 2004, 06:49 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Help with array...
OK I need some help. I am a bit of a beginner with C++. I have a small
project due and I am having a hard time even knowing where to start. I have
attempted a flow chart and pseudocode, and to no help I am still at ground zero.
I am not looking for someone to do it for me, just maybe point me in some type of
general direction. I will give to you the wording as it was to me:
Use a single subscripted array to solve the following problem. A company pays its sales
people on a commission basis. The sales people receive $200.00 per week plus 9 percent
of their gross sales for that week. For example, a sales person who grosses $5000 in
sales in a week receives $200 plus 9% of $5000, or a total of $650. Write a program using
an array of counters that determines how many of the sales people earned salaries in each of the
following ranges ( assume that each salesperson's salary is truncated to an integer amt ):
a) $200-$299
b) $300-$399
c) $400-$499
d) $500-$599
e) $600-$699
f) $700-$799
g) $800-$899
h) $900-$999
i) $1000 and over
1. The progam should process as many salespersons data that the user wants to enter. A solution might include
asking the user if there is salespersons to be processed or not
2. Use the array indexes ( subscripts ) to 'map' to the computed salary ranges. The data stored in the array
can represent the 'number of sales persons' in each of the computed salary ranges.
OK I am new to C++ I can do really basic things, and I mean basic so this I am having a hard time with this.
I have read and read and read the material that I was given and attempted to comprehend, but I really
don't even know where to start. Once again, I am not looking for someone to do it completely, maybe just help
me get started or get an idea. Any help/hints/tips greatly appreciated!!
Thanks
|

August 11th, 2004, 02:57 AM
|
|
Contributing User
|
|
Join Date: Jul 2003
Posts: 367
Time spent in forums: 7 m 21 sec
Reputation Power: 10
|
|
|
My first piece of advice would be to give it a go. Theres a million and one tutorials out there that will tell you how to set up a small c++ program that prints 'hello world' on the screen. Then from there read another that tells you about user input and play around with it. Keep reading tutorials and trying things out then when you have specific questions let us know we're always happy to help on things like that but don't really see what we can give you if you've made some pseudo code and a flow chart already.
-KM-
|

August 11th, 2004, 06:55 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
thanks  I have actually gotten it completed I think!!
!!!!!!!!!!! 
|

May 2nd, 2005, 03:05 PM
|
|
Registered User
|
|
Join Date: May 2005
Posts: 1
Time spent in forums: 9 m 41 sec
Reputation Power: 0
|
|
My Program is bumming.
Quote: | Originally Posted by Majestica thanks  I have actually gotten it completed I think!!
!!!!!!!!!!!  | - Can I get a copy of the program?
thanks,
|

May 28th, 2005, 03:49 PM
|
|
Registered User
|
|
Join Date: May 2005
Posts: 1
Time spent in forums: 9 m 54 sec
Reputation Power: 0
|
|
|
Did you get it working finally or are you still having problems? E-mail me what you have so I can take a look at it.
Thanks,
-CW
|

January 21st, 2013, 08:14 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 2
Time spent in forums: 1 h 41 m 23 sec
Reputation Power: 0
|
|
|
Salesman Sales and salary
A company pays its salespeople on a commission basis. The salespeople each receive $200 per week plus 9 percent of their gross sales for the sales period. For example, a salesperson who grosses $5000 in sales in the period receives $200 plus 9 percent of $5000, or a total of $650. Write a program determines for each salesperson their total sales and their salary. There are 5 salesmen for the company. The data file is "SalesPerson Sales.txt". It contains the salesperson number (1-5) followed by his sales. Each salesperson has numerous sales listed in the file.
List out each sales person's number, their total sales and their salary. Restriction: No arrays, use a switch statement, and use functions.
The problem is that I can't get the total sales (aka gross) to compute right. Here's my source code from c++:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
void number1();
void number2();
void number3();
void number4();
void number5();
ofstream outputFile;
ifstream inputFile;
double number = 0;
int salesman;
double gross1 = 0;
double gross2 = 0;
double gross3 = 0;
double gross4 = 0;
double gross5 = 0;
int main()
{
outputFile.open ("Salesman Salary.txt");
outputFile << " Salesman Sales and Salary\n\n";
cout << " Salesman Sales and Salary\n\n";
inputFile.open("Salesman Gross.txt");
cout << "Enter either 1, 5, or number in b/tw to view the salary table. ";
cin >> salesman;
cout << " SALESMAN\t" << "\tGROSS SALES" << "\tTOTAL SALARY\n";
outputFile << " SALESMAN\t" << "\tGROSS SALES" << "\tTOTAL SALARY\n";
switch (salesman)
{
case 1: inputFile >> number;
number++;
gross1 += number;
number1();
case 2: inputFile >> number;
number++;
gross2 += number;
number2();
case 3: inputFile >> number;
number++;
gross3 += number;
number3();
case 4: inputFile >> number;
number++;
gross4 += number;
number4();
case 5: inputFile >> number;
number++;
gross5 += number;
number5();
break;
default: cout << "Invalid Entry. Please restart and enter either 1, 5, or a number in between.";
}
outputFile.close();
inputFile.close();
return 0;
}
// Calculate Sales of Salesman 1.
void number1()
{
double Total1;
salesman = 1;
Total1 = 200 + (.09 * gross1);
cout << fixed << showpoint << setprecision(2);
cout << "\t1\t" << "\t $" << gross1 << "\t\t$" << Total1 << "\t\n";
outputFile << "\t1\t" << "\t $" << gross1 << "\t\t$" << Total1 << "\t\n";
}
// Calculate Sales of Salesman 2.
void number2()
{
double Total2;
salesman = 2;
Total2 = 200 + (.09 * gross2);
cout << fixed << showpoint << setprecision(2);
cout << "\t2\t" << "\t $" << gross2 << "\t\t$" << Total2 << "\t\n";
outputFile << "\t2\t" << "\t $" << gross2 << "\t\t$" << Total2 << "\t\n";
}
// Calculate Sales of Salesman 3.
void number3()
{
double Total3;
salesman = 3;
Total3 = 200 + (.09 * gross3);
cout << fixed << showpoint << setprecision(2);
cout << "\t3\t" << "\t $" << gross3 << "\t\t$" << Total3 << "\t\n";
outputFile << "\t3\t" << "\t $" << gross3 << "\t\t$" << Total3 << "\t\n";
}
// Calculate Sales of Salesman 4.
void number4()
{
double Total4;
salesman = 4;
Total4 = 200 + (.09 * gross4);
cout << fixed << showpoint << setprecision(2);
cout << "\t4\t" << "\t $" << gross4 << "\t\t$" << Total4 << "\t\n";
outputFile << "\t4\t" << "\t $" << gross4 << "\t\t$" << Total4 << "\t\n";
}
// Calculate Sales of Salesman 1.
void number5()
{
double Total5;
salesman = 5;
Total5 = 200 + (.09 * gross5);
cout << fixed << showpoint << setprecision(2);
cout << "\t5\t" << "\t $" << gross5 << "\t\t$" << Total5 << "\t\n";
outputFile << "\t5\t" << "\t $" << gross5 << "\t\t$" << Total5 << "\t\n";
}
This is my results:
Salesman Sales and Salary
SALESMAN GROSS SALES TOTAL SALARY
1 $3 $200.27
2 $11.8 $201.062
3 $4 $200.36
4 $151 $213.59
5 $2 $200.18
Can someone help me with the gross calculations?
|

January 22nd, 2013, 07:39 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 5
Time spent in forums: 6 m 45 sec
Reputation Power: 0
|
|
|

January 23rd, 2013, 07:33 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 1
Time spent in forums: 4 m 44 sec
Reputation Power: 0
|
|
|
good job,The salespeople each receive $200 per week plus 9 percent of their gross sales for the sales period. thanks
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|