Design a solution that prints the amount of pay a commissioned salesperson takes
ID: 672618 • Letter: D
Question
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?
Explanation / Answer
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sales_Calc
{
class Calculate
{
static void Main(string[] args)
{
string Total_Sales = "";
double sales = 0;
float commision = 0f;
Console.WriteLine("Please enter total sales amount for the week:");
Total_Sales = Console.ReadLine();
Sales=double.Parse(Total_Sales);
if (sales < 0)
{
Console.WriteLine("Please provide a valid sales figure!");
Console.ReadKey();
return;
}
if (sales < 1001) commision = 0.03f;
else
if (sales < 5001) commision = 0.05f;
else
if (sales <= 10000) commision = 0.06f;
Console.WriteLine("Commission is: {0} % = {1:##,###.##} $", commision * 100,
comsn * sales);
Console.WriteLine("Pay amount is: {0:##,###.##} $", sales - commision * sales);
Console.ReadKey();
}
}
}
else commision = 0.07f;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.