Thread: help w/ array problem

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    2

    help w/ array problem

    i'm having a problem with a homework question and i was hoping someone could give me a little help. Here it is:

    6.10 Use a single-subscripted array to solve the following problem. A company pays its salespeople on a commission basis. The salespeople recieve $200 per week plus 9 percent of their gross sales for that week. For example, a salesperson who grosses $3000 in sales in a week recieves $200 plus 9 percent of $3000, or a total of $470. Write a C 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):
    1. $200-$299
    2. $300-$399
    3. $400-$499
    4. $500-$599
    5. $600-$699
    6. $700-$799
    7. $800-$899
    8. $900-$999
    9. $1000 and over

    (end of problem)

    Now either this problem is so simple and i'm not reading it right or i just don't have a clue! Any help would be great!

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    well, try rereading the problem...but: check through the salaries using if statements to check values and add to the counters...for example

    array[0]++;

    hope this helps...

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    2

    problem w/array question

    <<mod snipped reposted question - answers merged into one thread>>

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    5
    I'm not going to write the program for you, but I'll help you out a bit. The exercise assumes that certain data is already present, such as data read from a datafile. Data that is unknown includes the number of total employees and each employee's weekly sales.

    Unless your instructor says otherwise, there are many different methods of creating samples to test out your program, such as a datafile or keyboard input. The easiest method in your case is to have a create a seperate array (initialized to the total amount of employees), and using a for loop with a scanf("%d", &array[i]) to read in each employee's weekly sales.

    Finding the the number of employees in each category requires a second array and some algebra.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array problem
    By TomBoyRacer in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2007, 11:35 AM
  2. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  3. Replies: 6
    Last Post: 02-15-2005, 11:20 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Need desperate help with two dimensional array problem
    By webvigator2k in forum C++ Programming
    Replies: 4
    Last Post: 05-10-2003, 02:28 PM