A company illustrates the use of a pay-type code to calculate an employee’s pay. Below are the formulas to calculate the pay for each pay – type code:
H = Hourly pay = rate * hours
P = Piece work pay = rate * number of pieces
C = Commission pay = commission * sales
S = Salary pay = salary
using System;
namespace Questions
{
class Program
{
static void Main()
{
Console.WriteLine("Please select pay-type code");
Console.WriteLine("H = Hourly");
Console.WriteLine("P = Piece work");
Console.WriteLine("C = Commision");
Console.WriteLine("S = Salary");
Console.Write("\n\nYour choice: ");
char payTypeCode = Console.ReadLine()[0];
decimal pay;
if(payTypeCode.Equals('H'))
{
Console.Write("hourly rate: ");
decimal hourlyRate = decimal.Parse(Console.ReadLine());
Console.Write("hours: ");
decimal hours = decimal.Parse(Console.ReadLine());
pay = hourlyRate * hours;
}
else if(payTypeCode.Equals('P'))
{
Console.Write("rate: ");
decimal rate = decimal.Parse(Console.ReadLine());
Console.Write("number of pieces: ");
decimal numberOfPieces = decimal.Parse(Console.ReadLine());
pay = numberOfPieces * rate;
}
else if(payTypeCode.Equals('C'))
{
Console.Write("commision: ");
decimal commision = decimal.Parse(Console.ReadLine());
Console.Write("sales: ");
decimal sales = decimal.Parse(Console.ReadLine());
pay = commision * sales;
}
else
{
Console.Write("salary: ");
decimal salary = decimal.Parse(Console.ReadLine());
pay = salary;
}
Console.WriteLine("\nPay = " + pay);
Console.ReadKey();
}
}
}
Comments
Leave a comment