Skip to content

Instantly share code, notes, and snippets.

@mstefarov
Forked from anonymous/salarycounter.cs
Created November 30, 2012 04:01
Show Gist options
  • Save mstefarov/4173705 to your computer and use it in GitHub Desktop.
Save mstefarov/4173705 to your computer and use it in GitHub Desktop.
Counts the amount of pay grades in each category.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
const double percentIncrease = 0.09;
static void Main(string[] args)
{
int[] grossSales = new int[]
{
200,
1100,
500,
700,
400,
5500,
290,
9050,
1026,
890,
};
int[] numOfSalariesInThatCategory = new int[9];
for(int i = 0; i<grossSales.Length; i++)
{
int totalPay = 200 + (int)Math.Round(grossSales[i] * percentIncrease);
if (totalPay >= 200 && totalPay < 1000)
{
numOfSalariesInThatCategory[totalPay / 100 - 2]++;
}
else if (totalPay >= 1000)
{
numOfSalariesInThatCategory[8]++;
}
}
Console.WriteLine("The amounts within salary categories are as follows:");
for(int i = 0; i<numOfSalariesInThatCategory.Length; i++)
{
Console.WriteLine(numOfSalariesInThatCategory[i]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment