Question #39231

Design a solution that prints the amount of pay a commissioned salesperson takes home. The more sales documented, the larger the commission rate.Allow the user to input a total sales amount for the week. Compute the commission based on the following table. Display the pay amount formatted with commas, decimals, and a dollar symbol.
less than $1000: 3% $1001–$5000: 5% $5001–$10000: 6% over $10000: 7%
Be sure to design your solution so that all possible situations are accounted for and tested. What values did you enter and test to verify your program’s correctness?

Expert's answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Q39321
{
    class Program
    {
        static void Main(string[] args)
        {
            string s_mon = "";
            double d_mon = 0;
            float comsn = 0f;
            Console.WriteLine("Please enter total sales amount for the week:");
            s_mon = Console.ReadLine();
            if (!Double.TryParse(s_mon.Replace('.', ','), out d_mon) || d_mon < 0)
            {
                Console.WriteLine("Wrong input!");
                Console.ReadKey();
                return;
            }
            if (d_mon < 1001) comsn = 0.03f;
            else
            if (d_mon < 5001) comsn = 0.05f;
            else
            if (d_mon <= 10000) comsn = 0.06f;
            else comsn = 0.07f;
            Console.WriteLine("Commission is: \t{0} % = {1:##,###.##} $", comsn * 100, comsn * d_mon);
            Console.WriteLine("Pay amount is: \t{0:##,###.##} $", d_mon - comsn * d_mon);
            Console.ReadKey();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS