Review the following scenario and complete the design Scenar

Review the following scenario and complete the design. Scenario You have been asked by the Payroll department to create a program that will calculate the weekly pay for the company’s 25 employees. The employee names and pay will be stored in arrays. The program will prompt the user to provide each employee’s full name, hourly pay rate, and hours worked. The program will then ask whether the employee is single or married. If an employee is married, the tax rate is 20%; if he or she is single, the tax rate is 25%. Also, if the employee worked more than 40 hours in a week, the number of hours greater than 40 is paid a rate 1.5 times the pay rate. After all data are input and calculated, the program will display a payroll report with a list of all the employee names and weekly pay. In addition, the program will display the total payroll for the week, and the average weekly pay. Write a program using C#, prompt the user for the appropriate input, and display the output as described above. You may assume all data are valid. Provide a program introduction message that tells the user how to use the program.

Solution

using System;

public class Test
{
   public static void Main()
   {
       string[] employee = new string[25];
       double[] pay = new double[25];
       double payRate,tax;
       int i,hoursWorked;
       string mstatus;
       tax = 0;
       for(i=0;i<25;i++)
       {
           Console.WriteLine(\"Enter employee’s full name\");
           employee[i] = Console.ReadLine();
           Console.WriteLine(\"Enter hourly pay rate\");
           payRate = Convert.ToDouble(Console.ReadLine());
           Console.WriteLine(\"Enter hours worked\");
           hoursWorked = Convert.ToInt32(Console.ReadLine());
           Console.WriteLine(\"Enter whether the employee is single or married<m-married,s-single>\");
           mstatus = Console.ReadLine();
           if(mstatus == \"m\")
           tax = 0.2;       //20 % tax for married
           else if(mstatus == \"s\")
           tax = 0.25; //25% tax for single
           if(hoursWorked <= 40) //if hours worked less than equal to 40
           pay[i] = hoursWorked * payRate;
           else
           pay[i] = 40*payRate + (hoursWorked -40)*payRate*1.5 ;//1.5 times pay for overtime
           pay[i] = pay[i] - pay[i]*tax;//deduct tax
       }
    for(i=0;i<25;i++)
       {
           Console.WriteLine(\"Employee\'s name : \"+employee[i] +\" pay : \"+pay[i]);
       }
   
      
   }
}

Review the following scenario and complete the design. Scenario You have been asked by the Payroll department to create a program that will calculate the weekly

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site