Question : C #  help please

Okay this is the question:

(Sales Commissions) Use a one-dimensional array to solve the following problem: A company pays its salespeople on a commission basis. The salespeople receive $200 commission basis per week plus 9% of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9% of $5000 (200+9%x5000), or a total of $650. Write an application (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): a) $200–299 b) $300–399 c) $400–499 d) $500–599 e) $600–699 f) $700–799 g) $800–899 h) $900–999 i) $1000 and over Summarize the results in tabular format. Hint: You might use an array to represent the above 9 ranges. An elements of the array would be a counter of the salespeople earned salaries in that range. You can use repetition statement to get user's input on sales amount. For example, a user could provide a list of sales numbers like the following: 4000 6000 5000 4500 5600 7800 9000 9010 8010 2020 ... (negative number indicates quit of inputting data)

this is the solution that worked:

namespace salary
{
   public class salary
   {
      public static void Main(string[] args)
      {
         
         double[] salary = { 0, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200 };
         int[] value = new int[11];

         Console.WriteLine("Please enter your total sales"); //prompt user for input

         int input = Convert.ToInt32(Console.ReadLine()); //read input from user

         for (int index = 0; index < (salary.Length); index++)
         {
            int sal = (int)(salary[index] * (0.09)) + 200;
            Console.WriteLine("Sales Person" + index + " Gets " + sal.ToString("C") + "<br/>");
            int range = sal / 100;
            value[range] = value[range] + 1;
         }
         for (int i = 2; i < value.Length; i++)
         {
            int lowerValue = i * 100;
            int upperValue = (i + 1) * 100 - 1;
            string output = String.Format("Range {0} - {1}....{2} Sales guy(s)", lowerValue, upperValue,



            Console.WriteLine(output + "<br/>");
         }

      }
   }
}

1. Implement a sort algorithm to sort the output of numbers of salesperson across different ranges.  2. Implement a search algorithm to allow users search based on number of salesperson. That is a user types in a number indicating the number of salespeople. Your program output the ranges that match this number.
im having trouble with this question.^^^^ help anyone please

Answer : C #  help please

If you want to enter data from keyboard - you need a while loop, something like in the snippet.

Can't get why do you need sorting?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
    class Program
    {
        static void Main(string[] args)
        {
            int[] salaryRange = { 300, 400, 500, 600, 700, 800, 900, 1000};
            int[] frequency = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            bool doContinue = true;
            while(doContinue)
            {
                Console.WriteLine("Please enter salary");
                string resultStr = Console.ReadLine();
                int result;
                bool canParse = int.TryParse(resultStr, out result);
                if (canParse)
                {
                    if (result < 200)
                    {
                        Console.WriteLine("Wrong input - salary cannot be less than 200");
                        continue; //ask for input again
                    }
                    else
                    {
                        for(int i =0;i<frequency.Length;i++){
                            if (i==8)
                            {
                                frequency[i] = frequency[i] + 1;
                            }
                            else if (result < salaryRange[i])
                            {
                                frequency[i] = frequency[i] + 1;
                                break;
                            }
                        }
                    }

                }
                else
                {
                    Console.WriteLine("Wrong input - should be numeric");
                    continue; //ask for input again
                }
                Console.WriteLine("Do you want to continue? Y/N");
                resultStr = Console.ReadLine();
                if (!(resultStr.ToLower() == "y"))
                {
                    doContinue = false;
                }

            }// end while

            // print results
            Console.WriteLine("\n\n===============\nFrequency");
            for (int i = 0; i< frequency.Length ; i++)
            {
                string lower;
                string upper;
                if (i == 0)
                {
                    lower = "200";
                }
                else
                {
                    lower = "" + (salaryRange[i-1]);
                }
                if (i == 8)
                {
                    upper = "over";
                }
                else
                {
                    upper = "" + (salaryRange[i]-1);
                }
                Console.WriteLine(lower + " - " + upper + ": \t" + frequency[i]);
            }
           
            Console.ReadLine();

        }
    }
Random Solutions  
 
programming4us programming4us