Question

C# Use a one-dimensional array to solve the following problem: A company pays its salespeople on...

C#

Use a one-dimensional array to solve the following problem: A company pays its salespeople on a commission basis. The salespeople receive $200 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, 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): The application will accept sales amount until the user enters -1 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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C SHARP CODE:

using System;
class MainClass {
    public static void Main (string[] args) {
        // Assuming there are max 100 sales persons
        int[] salary = new int[100];
        int size = 0, sales;
        Console.Write("Enter sales amount: ");
        // userInput = Console.Read();
        sales = Int32.Parse(Console.ReadLine());
        while(sales != -1){
            salary[size] = 200 + sales*9/100;
            size++;
            Console.Write("Enter sales amount: ");
            sales = Int32.Parse(Console.ReadLine());
        }
        Console.WriteLine("a) $200-299: " + getCount(salary, size, 200, 299).ToString());
        Console.WriteLine("b) $300-399: " + getCount(salary, size, 300, 399).ToString());
        Console.WriteLine("c) $400-499: " + getCount(salary, size, 400, 499).ToString());
        Console.WriteLine("d) $500-599: " + getCount(salary, size, 500, 599).ToString());
        Console.WriteLine("e) $600-699: " + getCount(salary, size, 600, 699).ToString());
        Console.WriteLine("f) $700-799: " + getCount(salary, size, 700, 799).ToString());
        Console.WriteLine("g) $800-899: " + getCount(salary, size, 800, 899).ToString());
        Console.WriteLine("h) $900-999: " + getCount(salary, size, 900, 999).ToString());
        Console.WriteLine("i) $1000 and over: " + getCount(salary, size, 1000, -1).ToString());
        
    }
    // Function to get number of salesperson between given salary range
    // both start and end inclusive
    public static int getCount(int[] salary, int size, int start, int end){
        int count = 0;
        for(int i = 0; i < size; i++){
            // Special case for 1000 and above
            if(start == 1000 && end == -1 && salary[i] >= start)
                count++;
            if(start <= salary[i] && salary[i] <= end)
                count++;
        }
        return count;
    }
}

SAMPLE OUTPUT:

FOR ANY HELP JUST DROP A COMMENT

Add a comment
Know the answer?
Add Answer to:
C# Use a one-dimensional array to solve the following problem: A company pays its salespeople on...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using one-dimensional array to calculate sales commissions of salespeople.

    ----using JavalanguageWritean application(using an array of counters) that determines how many of the salespeople earnedsalaries in each of the followingranges(assume that each salesperson's salary is truncated to an integer amount):a)$200-299b) $300-399c)$400-599d)$500-599e)600-699f) 700-799g)800-899h)900-999i)1000 and overThe salespeoplereceive $200 per weekplus 9% of theirgrosssalesfor that week.Summarize the results intabular format. I NEED SOME HELPRIGHT AWAYORMYGRADEFORTHECOURSE WILLBEGREATLY AFFECTED------PLEASE!!!!

  • Why am I getting the same results with my rand() every time I run my C++...

    Why am I getting the same results with my rand() every time I run my C++ program? I am trying to do this problem: each receive $200 per week plus 9 percent of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9 percent of $ 5000, or a total of $650. Write a program(using an array of counters) that determines how many of the salespeople earned salaries...

  • A large company pays its salespeople on a commission basis. The salespeople each receive $200 per...

    A large company pays its salespeople on a commission basis. The salespeople each receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of chemicals in a week reeives $200 plus 9% of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value 1 239.99 2 129.75 3 99.95 4...

  • Use a two-dimensional array to solve the following problem. A company has four salespeople (0 to...

    Use a two-dimensional array to solve the following problem. A company has four salespeople (0 to 3) who sell five different products (0 to 4). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains the following: a) The salesperson number b) The product number c) The total dollar value of that product sold that day Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that...

  • Use a two-dimensional array to solve the following problem. A company has four salespeople (1 to...

    Use a two-dimensional array to solve the following problem. A company has four salespeople (1 to 4) who sell five different products (1 to 5). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains the following a) The salesperson number b) The product number c) The total dollar value of that product sold that day Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that...

  • This Java program must use classes and object-oriented design (OOD) as I'm in a more advanced...

    This Java program must use classes and object-oriented design (OOD) as I'm in a more advanced Java class. (Sales Commission Calculator) A large company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of merchandise in a week receives $200 plus 9% of $5000, or a total of $650. You’ve been supplied with a list of the items sold...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT