0

Ok so I am Majoring in CIS, and in one of my classes I had to write a simple program that will calculate someones pay, but the prof. wants me to use ref and out parameters. Problem is I'm not sure how to start that off, can someone point me in the right direction, I've been stuck on it for 3 hours, I even reread the book. Thank you.

using System;
using System.Collections.Generic;
using System.Text;

namespace Lab3
{
    class Program
    {
        public static void Main(string[] args)
        {
            string employee;
            employee = GetEmployee();
            double regH, overH, payR;
            double grossP, netP;
            double fedTax = 0.28, ssTax = .0765;
            regH = GetRegH();
            overH = GetOverH();
            payR = GetPayR();
            grossP = CalculateGrossP(regH, overH, payR);
            fedTax = CalculateFed(fedTax, grossP);
            ssTax = CalculateSST(ssTax, grossP);
            netP = CalculateNet(grossP, fedTax, ssTax);
            DisplaySum(grossP, netP, fedTax, ssTax);
        }
        public static string GetEmployee()
        {
            Console.WriteLine("Enter Employee: ");
            return Console.ReadLine();
        }
        public static double GetRegH()
        {
            Console.WriteLine("Enter number of Regular Hours: ");
            return double.Parse(Console.ReadLine());
        }
        public static double GetOverH()
        {
            Console.WriteLine("Enter number of Over time Hours: ");
            return double.Parse(Console.ReadLine());
        }
        public static double GetPayR()
        {
            Console.WriteLine("Enter Pay Rate: ");
            return double.Parse(Console.ReadLine());
        }
        public static double CalculateGrossP(double r, double o, double p)
        {
            return r * p + (o * 1.5 * p);
        }
        public static double CalculateFed(double f, double g)
        {
            return f * g;
        }
        public static double CalculateSST(double s, double g)
        {
            return s * g;
        }
        public static double CalculateNet(double g, double f, double s)
        {
            return g - (f + s);
        }
        public static void DisplaySum(double g, double net, double fed, double sst)
        {
            Console.WriteLine("\n Gross Pay:                   " + "{0:C}", g);
            Console.WriteLine("\n Federal Income Tax withheld: " + "{0:C}", fed);
            Console.WriteLine("\n Social Security Tax withheld: " + "{0:C}", sst);
            Console.WriteLine("\n Net Pay:                      " + "{0:C}", net);

        }
    
    }
 }
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by LizR
0

Well that looks like a reasonsable start, have you seen the examples in the helpfile for out and so on?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.