in c # language You will need to design an application that it will prompt a use
ID: 3664880 • Letter: I
Question
in c # language You will need to design an application that it will prompt a user for his or her hourly pay rate; his or her hours worked; and whether he or she is single, married, divorced, or widowed. It will then calculate the user’s gross and net pay. If the user works more than 40 hours, overtime is calculated at 1 ½ times the regular rate and displayed separately. If he or she is married, use a flat tax rate of 15%. If he or she is single, use 22%; if he or she is divorced, use 23%; and if he or she is widowed, use 13% (I realize that these are not very realistic). Below is a sample of what the program should do when run.
Explanation / Answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleAssignment
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter your hourly pay rate:");
Double hpr = 0;
hpr =Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter no of hours worked:");
Double nHours = 0;
nHours = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter Your Status (1/2/3/4): 1 - Single, 2 - Married, 3-divorced, 4-widowed:");
int status = 0;
status = Convert.ToInt16(Console.ReadLine());
Double grossPay = 0;
Double netPay = 0; //Gross-tax
//If the user works more than 40 hours, overtime is calculated at 1 ½ times the regular rate
Double overTimePay = (nHours > 40 ? (nHours - 40) : 0) * (1.5 * hpr);
Double regularPay = nHours * hpr;
grossPay = regularPay + overTimePay;
//If he or she is married, use a flat tax rate of 15%. If he or she is single, use 22%; if he or she is divorced, use 23%; and if he or she is widowed, use 13%
Double tax = 0;
if (status == 1)
tax = grossPay * 0.22;
else if (status == 2)
tax = grossPay * 0.15;
else if (status == 3)
tax = grossPay * 0.23;
else if (status == 4)
tax = grossPay * 0.13;
netPay = grossPay - tax;
Console.WriteLine("Regular Pay : {0} Over Time Pay: {1} Gross Pay : {2} Net pay: {3}", regularPay, overTimePay, grossPay, netPay);
Console.ReadKey();
}
}
}
---output----
Enter your hourly pay rate:
10
Enter no of hours worked:
45
Enter Your Status (1/2/3/4): 1 - Single, 2 - Married, 3-divorced, 4-widowed:
1
Regular Pay : 450
Over Time Pay: 75
Gross Pay : 525
Net pay: 409.5
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.