TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Avinash anand
NA
3
549
program showing no error but didn' giving appropriate result
Sep 8 2018 11:10 AM
this program is to take input from the user like his name and sales for week, for which it will calculate the grosspay, fedtax, socialsec deduction and total deduction but every time i run it, it does not shows appropriate result. please help
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace totalSalaryCalculator
{
class totalsalarycalculator
{
static void Main(string[] args)
{
string employeeName;
double saleForWeek;
double grossPay;
double fedTaxDeduction;
double socialSecDeduction;
double totalDeductions;
double takeHomePay;
double retirementContri;
DisplayInstructions();
employeeName = "Avinash";
saleForWeek = 1000;
grossPay = 8 * saleForWeek / 100;
retirementContri = 10 * grossPay / 100;
socialSecDeduction = 7 * grossPay / 100;
fedTaxDeduction = 12 * grossPay / 100;
totalDeductions = fedTaxDeduction + socialSecDeduction;
takeHomePay = grossPay + retirementContri - totalDeductions;
DisplayResults(employeeName, saleForWeek, grossPay, fedTaxDeduction, socialSecDeduction, retirementContri, takeHomePay);
}
public static void DisplayInstructions()
{
Console.WriteLine("\nYou will be asked to enter your name");
Console.WriteLine("\nAnd You will be asked to enter the total sale you were able to achieve for a week");
Console.WriteLine();
Console.WriteLine("Press any key when you are ready to begin");
Console.ReadKey();
Console.Clear();
}
public static double GetInformation(string name, string sale)
{
string inputvalue;
string inputvalue2;
double totalSales;
double nameOfPerson;
Console.Write("Enter the name of Employee: ");
inputvalue = Console.ReadLine();
nameOfPerson = double.Parse(inputvalue);
Console.Write("Enter the Total Sales for the Week: ");
inputvalue2 = Console.ReadLine();
totalSales = double.Parse(inputvalue2);
return (nameOfPerson + totalSales);
}
public static double GetGrossPay(double saleForWeek)
{
double grossPay;
grossPay = 8 * saleForWeek / 100 ;
return grossPay;
}
public static double fedTaxDeduction(double grossPay)
{
double fedTaxDeduction;
fedTaxDeduction = 12 * grossPay / 100;
return fedTaxDeduction;
}
public static double retirementContri(double grossPay)
{
double retirementContri;
retirementContri = 10 * grossPay / 100;
return retirementContri;
}
public static double socialSecDeduction(double grossPay)
{
double socialSecDeduction;
socialSecDeduction = 7 * grossPay / 100;
return socialSecDeduction;
}
public static double totdeductions(double fedTaxDeduction, double socialSecDeduction)
{
double totdeductions;
totdeductions = fedTaxDeduction + socialSecDeduction;
return totdeductions;
}
public static double takeHomePay(double grossPay, double totalDeductions)
{
double takeHomePay;
takeHomePay = grossPay - totalDeductions;
return takeHomePay;
}
public static void DisplayResults(string employeeName, double saleForWeek, double grossPay, double fedTaxDeduction, double retirementContri, double socialSecDeduction,
double takeHomePay)
{
Console.WriteLine("Employee Name: " + employeeName);
Console.WriteLine("Total Sales entered by the Employee: " + saleForWeek + "$");
Console.WriteLine("Gross Pay for a week: " + grossPay + "$");
Console.WriteLine("Federal Tax Deduction for a week: " + fedTaxDeduction + "$");
Console.WriteLine("Social security Deduction for a week: " + socialSecDeduction + "$");
Console.WriteLine("Retirement Contribution for a week: " + retirementContri + "$");
Console.WriteLine("Total Deductions for a week: " + totdeductions(fedTaxDeduction, socialSecDeduction) + "$");
Console.WriteLine("Take Home Pay for a week: " + takeHomePay + "$");
Console.ReadKey();
}
}
}
Reply
Answers (
2
)
i have problem in my code please help me trouble shoot.
C# code to execute ubuntu shell command