Hey so I am in a class where we are using Microsoft C++ and right now we are working on a program using arrays. We are given a problem where we have to sort people's salaries into categories of how much money they earn. So if they make $200-$299 they are in a category and if the earn $300-$399 they are in a different category and so on. I get my program to calculate the salary but when it goes into the categories, it puts a 1 in all the categories when it is only supposed to go into one certain category. Please help!!!!
Here is my code!!
#include <iostream>
#include <conio.h>
using namespace std;
int main(){
char again='y';
while(again == 'y')
{
system ("CLS");
int salary[9] = {0} , grosssales, earnedsalary;
cout << "Enter the salesperson's gross sales: $";
cin >> grosssales;
earnedsalary = 200 + grosssales*.09;
cout << "The earned salary for this salesperson is: $" << earnedsalary << endl;
if(200 <= earnedsalary <= 299)
salary[0]++;
cout << "\nSalaries in the range of $200-$299: " << salary[0]++;
if(300 <= earnedsalary <= 399)
salary[1]++;
cout << "\nSalaries in the range of $300-$399: " << salary[1]++;
if(400 <= earnedsalary <= 499)
salary[2]++;
cout << "\nSalaries in the range of $400-$499: " << salary[2]++;
if(500 <= earnedsalary <= 599)
salary[3]++;
cout << "\nSalaries in the range of $500-$599: " << salary[3]++;
if(600 <= earnedsalary <= 699)
salary[4]++;
cout << "\nSalaries in the range of $600-$699: " << salary[4]++;
if(700 <= earnedsalary <= 799)
salary[5]++;
cout << "\nSalaries in the range of $700-$799: " << salary[5]++;
if(800 <= earnedsalary <= 899)
salary[6]++;
cout << "\nSalaries in the range of $800-$899: " << salary[6]++;
if(900 <= earnedsalary <= 999)
salary[7]++;
cout << "\nSalaries in the range of $900-$999: " << salary[7]++;
if(earnedsalary >= 1000)
salary[8]++;
cout << "\nSalaries greater than $1000: " << salary[8]++;
//cout << "\nSalaries in the range of $200-$299: " << salary[0]++;
//cout << "\nSalaries in the range of $300-$399: " << salary[1]++;
//cout << "\nSalaries in the range of $400-$499: " << salary[2]++;
//cout << "\nSalaries in the range of $500-$599: " << salary[3]++;
//cout << "\nSalaries in the range of $600-$699: " << salary[4]++;
//cout << "\nSalaries in the range of $700-$799: " << salary[5]++;
//cout << "\nSalaries in the range of $800-$899: " << salary[6]++;
//cout << "\nSalaries in the range of $900-$999: " << salary[7]++;
//cout << "\nSalaries greater than $1000: " << salary[8]++;
cout << "\n\nWould you like to calculate another saleperson's wage? y/n" << endl;
again = 'y';
I used all of these suggestions but i am still having problems. When the earnedsalary is $250, the salary categories up until "greater than 1000" all contain a 1 and the "greater than 1000" contains a 0.