2
Answers

I need help with my C# Homework ? What did I do wrong.

Jenni Witzel

Jenni Witzel

16y
2.4k
1
This program is suppose to takes input from the user, calculates payroll information. I dont know what i did wrong, did i miss something

using System;
using SC = System.Console;
public class JKingLab04
{ // Main Method
    public static void Main()
    {
        Double hoursWorked, payRate;
        Double grossPay, stateTax, federalTax = 0, dblFICA = 0,
        netPay = 0;

        SC.WriteLine("Lab 4 – Jenni King");
        SC.Write("\nPlease input hours worked: ");
        hoursWorkedStr = SC.ReadLine();
        SC.Write("\nPlease input rate of pay: ");
        payRateStr = SC.ReadLine();
        hoursWorked = Convert.ToDouble(hoursWorkedStr);
        payRate = Convert.ToDouble(payRateStr);


        grossPay = CalcGrossPay(hoursWorked, payRate);
        CalcStateTax(out stateTax, grossPay);
        CalcFedTax(ref federalTax, ref grossPay);
        CalcFICATax(ref dblFICA, ref grossPay);
        CalcNetPay(ref netPay, ref grossPay, ref stateTax,
                   ref federalTax, ref dblFICA);

        SC.WriteLine("grossPay = hoursWorked * rateOfPay");
       
    }

    public static double CalcGrossPay(double hours, double rate)
    {
        double gross;
        gross = hours * rate;
        return gross;
    }
    
 
    public static void CalcStateTax(out double stateTax, double grossPay)
    {
        stateTax = grossPay * 0.04;
    }

    public static void CalcFedTax(ref double federalTax, ref double grossPay)
    {
         federalTax = grossPay * 0.23;
    }

    public static void CalcFICATax(ref double fica, ref double grossPay)
    {
         fica = grossPay * 0.14;
    }

    public static void CalcNetPay(ref double netPay, ref double grossPay,
         ref double stateTax, ref double federalTax, ref double dblFICA)
    {
         netPay = grossPay - (0.04 + 0.23 + 0.14);
         grossPay = hoursWorked * rateOfPay;
         stateTax = grossPay * 0.04;
         federalTax = grossPay * 0.23;
         dblFICA = grossPay * 0.14;
    }
}

Answers (2)