Create a console-based program named Commission. Its Main() method calls two oth
ID: 3529332 • Letter: C
Question
Create a console-based program named Commission. Its Main() method calls two other methods. The first called method should ask a salesperson for the dollar value of daily sales and return the entered value to the Main() method. (Assume all sales are in whole dollars.) The second called method should calculate the salesperson's commission based on the rates in the accompanying table. The dollar value of the calculated commission should be returned to the Main() method, which then displays the value. Save the file as Commission.esExplanation / Answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Commission
{
class Commission
{
static int getSale() {
Console.Write("Enter sales total: ");
int sales = int.Parse(Console.ReadLine());
return sales;
}
static double getCommission(int sales) {
double commission;
if (sales < 0)
commission = 0;
else if (sales > 0 && sales < 1000)
commission = sales * .03;
else if (sales >= 1000 && sales <= 2999)
commission = sales * .04;
else
commission = sales * .05;
return commission;
}
static void Main(string[] args)
{
int sales = getSale();
double commission = getCommission(sales);
Console.WriteLine("The commission is {0:C}", commission);
Console.ReadLine(); Console.ReadLine(); //stall compiler from closing for 2 line reads
}//end main
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.