473,237 Members | 1,258 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 software developers and data experts.

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 6317
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

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

Similar topics

4
by: Venkat | last post by:
Hi All, I need to copy strings from a single dimensional array to a double dimensional array. Here is my program. #include <stdio.h> #include <stdlib.h>
2
by: ip4ram | last post by:
I used to work with C and have a set of libraries which allocate multi-dimensional arrays(2 and 3) with single malloc call. data_type **myarray =...
6
by: Ruben | last post by:
I'm trying to pass an array of string to a function without knowing how many strings I have beforehand. I've defined one functions as char * insert(char table,int cols, char values); out of...
60
by: Peter Olcott | last post by:
I need to know how to get the solution mentioned below to work. The solution is from gbayles Jan 29 2001, 12:50 pm, link is provided below: >...
22
by: spam.noam | last post by:
Hello, I discovered that I needed a small change to the Python grammar. I would like to hear what you think about it. In two lines: Currently, the expression "x" is a syntax error. I suggest...
8
by: per9000 | last post by:
Hi all, I have a two-dimensional array of data, f.x int's. We can imagine that the array is "really large". Now I want the data in it and store this in a one-dimensional array. The obvious...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
5
by: nelly0 | last post by:
developing a program that will manipulate noise levels (measured in decibels) that is collected by car manufacturers. These noise levels are produced at seven different speeds by a maximum of six...
4
by: =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= | last post by:
Hi, consider the attached code. Serializing the multi-dimensional array takes about 36s vs. 0.36s for the single-dimensional array. Initializing the multi-dimensional array takes about 4s...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.