C# programming Write a program that calculates and prints the take-home pay for
ID: 3882787 • Letter: C
Question
C# programming
Write a program that calculates and prints the take-home pay for a commissioned sales employee. Allow the user to enter values for the name of the employee and the sales amount for the week. Employees receive 7% of the total sales as their commission. Use federal tax rate as 18%. Retirement contribution is 15%. Use Social Security tax rate as 9%. Define appropriate constants. Write input, display, and calculation methods for each of the deductions. Your final output should display all calculated values, including the total deductions and all defined constants.Explanation / Answer
Here is the program
using System;
namespace WhatsMyInfo
{
public class Program
{
public static void Main()
{
string name;
float week,Federal,soc,Retirement;
float gross,toatal_deduction,home_pay;
Console.Write("Employee name: ");
name = Console.ReadLine();
Console.Write("This Week's sales : ");
week = Convert.ToInt32(Console.ReadLine());
//Print a blank line
Console.WriteLine();
//Show the details
Console.WriteLine("Commision Rate : 0.07");
Console.WriteLine();
gross = week * 7/100; // gross is the 7% of week's sale
Federal = gross * 18/100; // it is the 18% of the gross
soc = gross * 9/100;
Retirement = gross * 15/100;
toatal_deduction = Federal + soc + Retirement;
home_pay = gross - toatal_deduction;
Console.WriteLine("Gross Pay : ${0}", gross.ToString("0.00")); // make it two floating point
Console.WriteLine("Federal Taxes Withheld : (18 %): ${0}", Federal.ToString("0.00"));
Console.WriteLine("Soc. Sec. Taxes Withheld : (9 %): ${0}", soc.ToString("0.00"));
Console.WriteLine("Retirement Contribution : (9 %): ${0}", Retirement.ToString("0.00"));
Console.WriteLine("Toatal Deduction : ${0}", toatal_deduction.ToString("0.00"));
Console.WriteLine("Take Home Pay : ${0}", home_pay.ToString("0.00"));
}
}
}
to make two digits after the dot ie two floating point by or using the variable.ToString("0.00");
{0} is used to give the computer that is the firs variable it is not necessary
plz comment if there is anything wrong
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.