468,505 Members | 1,997 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,505 developers. It's quick & easy.

One dimensional array using an array of counters

I'm having ALOT of trouble understanding this (C++)..and i don't think i'm even close to getting this right. Please help. The problem reads as follows:

Use a one dimensional array to solve. A company pays on a commission basis. the salespeople receive $200 per week plus 9 percent of their gross sales for that week. (salesperson grosses 5000 in a week receives 200 plus 9 percent of 5000, total of 650) Write a program, using an array of counters, that determines how many of the salespeople earned salaries in each of the following ranges (assume that each salesperson's salary is truncated to an integer amount)
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

this is what i have so far:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

#include <iomanip>
using std::setw;
int main()
{
const int frequencySize = 11;
int frequency[ frequencySize ] = {};
int grossSales;
int total;





{

cout << "Enter employees gross sales: ";
cin >> grossSales;
cout << "Salary: " << grossSales * .09 + 200;





cout << "\nSalary:" << endl;}



for ( int count = 2; count < frequencySize; count++ )
{
if ( count == 2 )
cout << "$200-299: ";
else if ( count == 1000 )
cout << " $1000 ";
else
cout << "$" << count * 100 << "-" << ( count * 100 ) + 99 << ": ";



for ( int stars = 0; stars < frequency[ count ]; stars++ )
cout << '*';

cout << endl;

}



return 0;

}
i can't get the stars to appear beside the range and i don't know how to keep the loop going after the first salary is entered (while loop?)
Dec 6 '07 #1
1 5550
gpraghuram
1,275 Expert 1GB
I'm having ALOT of trouble understanding this (C++)..and i don't think i'm even close to getting this right. Please help. The problem reads as follows:

Use a one dimensional array to solve. A company pays on a commission basis. the salespeople receive $200 per week plus 9 percent of their gross sales for that week. (salesperson grosses 5000 in a week receives 200 plus 9 percent of 5000, total of 650) Write a program, using an array of counters, that determines how many of the salespeople earned salaries in each of the following ranges (assume that each salesperson's salary is truncated to an integer amount)
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

this is what i have so far:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

#include <iomanip>
using std::setw;
int main()
{
const int frequencySize = 11;
int frequency[ frequencySize ] = {};
int grossSales;
int total;





{

cout << "Enter employees gross sales: ";
cin >> grossSales;
cout << "Salary: " << grossSales * .09 + 200;





cout << "\nSalary:" << endl;}



for ( int count = 2; count < frequencySize; count++ )
{
if ( count == 2 )
cout << "$200-299: ";
else if ( count == 1000 )
cout << " $1000 ";
else
cout << "$" << count * 100 << "-" << ( count * 100 ) + 99 << ": ";



for ( int stars = 0; stars < frequency[ count ]; stars++ )
cout << '*';

cout << endl;

}



return 0;

}
i can't get the stars to appear beside the range and i don't know how to keep the loop going after the first salary is entered (while loop?)


HI,
Please dont double post...wait for members to reply to your query.

Thanks
Raghuram
Dec 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Ruben | last post: by
60 posts views Thread by Peter Olcott | last post: by
22 posts views Thread by spam.noam | last post: by
272 posts views Thread by Peter Olcott | last post: by
5 posts views Thread by nelly0 | last post: by
4 posts views Thread by =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
reply views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.