Hi everyone,

I am new to C# and also new to programming and I'm having a blonde moment. I have been working on this project for a week but have not figured out how to work this one out. I would appreciate any help you can provide.

1. Output total number of salary ranges:
200 - 299, 300-399, 400-499, 500-599, 600-699, 700-799, 800-899,
1000+
2. Input gross sales.
3. If quit (-1) go to step 8
4. Calculate the salary =$200 + 9% * gross sales (entered by user)
5. Determine the salary range that the calculated salary falls into.
6. Increment a counter for the salary range determined.
7. Repeat steps 2 thru 6.
8. Display a summary of the number of salaries falling into the salary ranges
as indicated.
9. Exit the program.

static void Main(string[] args)
{
int sales;
do
{
Console.Write("Enter in the sales for the salesperson (-1 to quit): ");
sales = int.Parse(Console.ReadLine());
} while (sales != -1);
{
int[] salesArray = new int[sales];
for (int counter = 0; counter < sales; counter++)
sales = 200 + ((9 / 10) * sales);
//store sales in each salary range
int[] frequency = new int[9];
 
//for each sales frequency increment appropriate counter
foreach (int sales in salesArray)
++frequency[sales / 100];

//for each sales, print number
for (int count = 0; count < frequency.Length; count++)
{
if (count == 100)
Console.Write("1000 and over: ");
else
Console.Write("{0:D2}{1:D2}: ", count * 100, count * 100 + 9);
}

Console.WriteLine("{0,20}{1,30}", "Salary Range", "Number of Salespeople");



}
}
}
}

Is this what you are Looking for ?

using System;
using System.Collections.Generic;
using System.Text;
namespace Blondee2007.cs
{
class Program
{
 
static void Main(string[] args)
{
int sales = 0;
int[] salesArray = new int[10];
while (sales > -1)
{
Console.Write("Enter in the sales for the salesperson (-1 to quit): ");
sales = int.Parse(Console.ReadLine());
if (sales < 0) { continue; }
 
sales = sales + (int)System.Math.Round( 0.09 * sales);
int item = (int)System.Math.Round( (decimal)(sales / 100) );
item = item > 9 ? 9 : item -1;
salesArray[item]++;
} // while
Console.WriteLine("{0}: {1}", "0 -199", salesArray[0]);
Console.WriteLine("{0}: {1}", "200-299", salesArray[1]);
Console.WriteLine("{0}: {1}", "300-399", salesArray[2]);
Console.WriteLine("{0}: {1}", "400-499", salesArray[3]);
Console.WriteLine("{0}: {1}", "500-599", salesArray[4]);
Console.WriteLine("{0}: {1}", "600-699", salesArray[5]);
Console.WriteLine("{0}: {1}", "700-799", salesArray[6]);
Console.WriteLine("{0}: {1}", "800-899", salesArray[7]);
Console.WriteLine("{0}: {1}", "900-999", salesArray[8]);
Console.WriteLine("{0}: {1}", "1000+ ", salesArray[9]);
Console.WriteLine("Press Enter to Quit");
Console.ReadLine();
}
 
}
}

Thank you Jerry. You are a lifesaver. I've spent hours and hours pouring over books and yanking my hair out. I just returned from Barnes and Noble - I pulled out all their C# books but could not find the answer to my question. Thank you, thank you, thank you.

This article has been dead for over six months. Start a new discussion instead.