Array of counters?

where I can use the array?

Page 1 of 1

9 Replies - 13571 Views - Last Post: 28 December 2010 - 08:23 AM Rate Topic: -----

#1 Hayaa   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 28-December 10

Array of counters?

Posted 28 December 2010 - 07:24 AM

Hi ...

can you tell me please where I can use the array in this Question ?

Use one –dimensional array to solve the following problem. A company pays its salespeople on a commission basis. The salespeople each receive $200 per week plus 9 percent of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receive $200 plus 9 percent of $5000, or 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):

I solve it with out using array, because I don't understand the question clear ...
my code ..

#include<iostream>
using namespace std;

int main()
{
	int earned;
	int i=0;
	const int size=8;
	while(i<size)
	{
		int grossSales;
	cout<<"Enter the Gross sales for this week: \n";
	cin>>grossSales;
	earned=((grossSales*9)/100)+200;
	cout<<"The sales person earned this week in range: \n";

		if(earned>=200 && earned<300)
			cout<<"$200-$299"<<endl;

		if(earned>=300 && earned<400)
			cout<<"$300-$499"<<endl;

		if(earned>=400 && earned<500)
			cout<<"$400-$599"<<endl;

		if(earned>=500 && earned<600)
			cout<<"$500-$699"<<endl;

		if(earned>=600 && earned<700)
			cout<<"$600-$799"<<endl;

		if(earned>=700 && earned<800)
			cout<<"$700-$899"<<endl;

		if(earned>=800 && earned<900)
			cout<<"$800-$999"<<endl;

		if(earned>=1000)
			cout<<"$1000 and over"<<endl;
	i++;
	}
	return 0;
}



:dozingoff:

Is This A Good Question/Topic? 0
  • +

Replies To: Array of counters?

#2 janotte   User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Array of counters?

Posted 28 December 2010 - 07:32 AM

Let's break it down.
You are being asked to use a 1D array of counters
What do you think that means?
Spell it out for us.

EDIT
I looked more closely at your code.
Your 'solution' deals with a 'salesperson' but the question is about 'salespeople'.
Singular vs plural.
Perhaps focussing on that bit of the requirements would make it clearer to you that you have misunderstood what you are being asked to do.

This post has been edited by janotte: 28 December 2010 - 07:40 AM

Was This Post Helpful? 0
  • +
  • -

#3 Hayaa   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 28-December 10

Re: Array of counters?

Posted 28 December 2010 - 07:42 AM

I don't know may be counting the earned for salesperson ...

really I don't know I think alot about it ,but there is no idea ...
Was This Post Helpful? 0
  • +
  • -

#4 janotte   User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Array of counters?

Posted 28 December 2010 - 07:43 AM

See my (too late) edit above.
You are thinking in the singular.
The challenge is in the plural.
Try reading the requirements out aloud slowly. You aren't understanding what you are being asked to do.
When I get confused reading things aloud helps me understand things better.
Was This Post Helpful? 1
  • +
  • -

#5 shad0wk1   User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 139
  • Joined: 01-October 10

Re: Array of counters?

Posted 28 December 2010 - 07:51 AM

I would guess English is not your native language. Just as janotte pointed out. A hint:

Quote

Write a program (using an array of counters)that determines how many of the salespeople earned salaries in each of the following ranges


Btw, usually in this kinda of range problems, we use if-else structure.

if   (earned>=200 && earned<300)
     cout<<"$200-$299"<<endl;
else if(earned>=300 && earned<400)
     cout<<"$300-$499"<<endl;
//continue


Was This Post Helpful? 0
  • +
  • -

#6 Hayaa   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 28-December 10

Re: Array of counters?

Posted 28 December 2010 - 07:59 AM

Declare an array that I put the values and calculate the earned then compare the value with the range , then determined the range !?

:dontgetit:
Was This Post Helpful? 0
  • +
  • -

#7 shad0wk1   User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 139
  • Joined: 01-October 10

Re: Array of counters?

Posted 28 December 2010 - 08:07 AM

Ah hahaha. :rolleyes:

In my opinion, it wants the number of salesperson for each range stored in array. Maybe for an int array named counter and initialized by 0, for range 200<salary<300 the number of salesperson that get salary in that range is put inside counter[0]. Then range 300<salary<400 the number of salesperson that get salary in that range is put inside counter[1]. and so on. The increment can be done easily maybe using counter[0]++;

That should be quite comprehensible.

[edit] tell me if I help him too much. >.>;

This post has been edited by shad0wk1: 28 December 2010 - 08:08 AM

Was This Post Helpful? 2
  • +
  • -

#8 janotte   User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Array of counters?

Posted 28 December 2010 - 08:12 AM

Seems like good advice and well given for the little my opinion is worth.
Was This Post Helpful? 0
  • +
  • -

#9 Hayaa   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 28-December 10

Re: Array of counters?

Posted 28 December 2010 - 08:13 AM

Ahha ...

the array counting how many salespeople in each range earned..

that mean if there are two salespeople earned 200-299$ then increment two in subscript for range 200-299$ ...
Was This Post Helpful? 0
  • +
  • -

#10 Hayaa   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 28-December 10

Re: Array of counters?

Posted 28 December 2010 - 08:23 AM

janotte , shad0wk1

Thank you for helping me and clearing the meaning .

with my wishes for you have a Happy Enjoyable life .

shad0wk1 .. yah the English is not my native language :rolleyes:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1