Got a problem getting this program to work. It needs to accepts weeklySales from
ID: 3545648 • Letter: G
Question
Got a problem getting this program to work. It needs to accepts weeklySales from the user and calculate and display the variables listed in the code.
//-------------------------------------------
//Programming Assignment: LAB1C
//Developer: Stephen Dunn
//Date Written: 11/03/2013
//Purpose: Calculate Total Earnings
//-------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LAB1C
{
class Program
{
static void Main(string [] Args)
{
//create variables and set values
double grossPay, fedTax, socSecurity, retirement, totalDeductions, takeHomePay;
string weeklySales;
Console.Write("Please enter your weekly sales: ");
weeklySales = Console.ReadLine();
weeklySales=();
//perform calculation
grossPay = weeklySales * .07;
fedTax = grossPay * .18;
socSecurity = grossPay * .06;
retirement = grossPay * .1;
totalDeductions = fedTax + socSecurity + retirement;
takeHomePay = grossPay - fedTax - retirement - socSecurity;
//display deductions and earnings
System.Console.WriteLine("Your Total Weekly Sales are: ");
Console.WriteLine(weeklySales);
System.Console.WriteLine("Your Total Federal Tax Deduction is: ");
Console.WriteLine (fedTax);
System.Console.WriteLine("Your Gross Pay is:");
Console.WriteLine (grossPay);
System.Console.WriteLine("Your Total Deduction is:");
Console.WriteLine (totalDeductions);
System.Console.WriteLine("Your Social Security contribution is:");
Console.WriteLine(socSecurity);
System.Console.WriteLine("Your Retirement Contribution is:");
Console.WriteLine(retirement);
System.Console.WriteLine("Your Total Deductions are:");
Console.WriteLine(totalDeductions);
System.Console.WriteLine("Your Take Home Pay is:");
Console.WriteLine(takeHomePay);
}
}
}
Explanation / Answer
namespace LAB1C
{
class Program
{
static void Main(string[] Args)
{
//create variables and set values
double grossPay, fedTax, socSecurity, retirement, totalDeductions, takeHomePay;
string weeklySales;
Console.Write("Please enter your weekly sales: ");
weeklySales = Console.ReadLine();
//perform calculation
grossPay = Double.Parse(weeklySales) * .07;
fedTax = grossPay * .18;
socSecurity = grossPay * .06;
retirement = grossPay * .1;
totalDeductions = fedTax + socSecurity + retirement;
takeHomePay = grossPay - fedTax - retirement - socSecurity;
//display deductions and earnings
System.Console.WriteLine("Your Total Weekly Sales are: ");
Console.WriteLine(weeklySales);
System.Console.WriteLine("Your Total Federal Tax Deduction is: ");
Console.WriteLine (fedTax);
System.Console.WriteLine("Your Gross Pay is:");
Console.WriteLine (grossPay);
System.Console.WriteLine("Your Total Deduction is:");
Console.WriteLine (totalDeductions);
System.Console.WriteLine("Your Social Security contribution is:");
Console.WriteLine(socSecurity);
System.Console.WriteLine("Your Retirement Contribution is:");
Console.WriteLine(retirement);
System.Console.WriteLine("Your Total Deductions are:");
Console.WriteLine(totalDeductions);
System.Console.WriteLine("Your Take Home Pay is:");
Console.WriteLine(takeHomePay);
Console.Read();
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.