Thursday, October 7, 2010

Code for Assignment 2

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

namespace Assignment2
{
class Program
{

double grossPay;

static void Main(string[] args)
{
Program prog = new Program();
prog.GetNumbers();
Console.ReadKey();
}

void GetNumbers()
{
Console.WriteLine("Enter the Rate");
double rate = double.Parse(Console.ReadLine());
Console.WriteLine("Enter the hours");
double hours = double.Parse(Console.ReadLine());
CalculateGross(rate, hours);
CalculateTotalDeductions();
}

void CalculateGross(double rt, double hrs)
{
grossPay = rt * hrs;
Console.WriteLine("The Product is {0}", grossPay.ToString("c"));
}

double CalculateSocialSecurity()
{
return grossPay * .2;
}

double CalculateMedicare()
{
return grossPay * .05;
}

void CalculateTotalDeductions()
{
double ss = CalculateSocialSecurity();
double md = CalculateMedicare();
double totalDeductions = ss + md;
Console.WriteLine("the total deductions are {0}", totalDeductions.ToString("c"));
}

}//class
}

No comments:

Post a Comment