Answer to Question #257783 in C# for Maa

Question #257783

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:

= Hourly        pay = rate * hours

= Piece work     pay = rate * number of pieces

= Commission    pay = commission * sales

= Salary         pay = salary



1
Expert's answer
2021-10-27T18:50:51-0400
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();
        }
    }


}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS