Here is the starting code for Assignment 2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Assignment2
{
class Program
{
const double SOCSEC = .09;
static void Main(string[] args)
{
Program p = new Program();
p.Display();
p.PauseIt();
}//end main
private void Display()
{
Console.WriteLine("Enter the hours worked this week");
double hours = double.Parse(Console.ReadLine());
Console.WriteLine("Enter the rate per hour");
double rate = double.Parse(Console.ReadLine());
double weeklyGross = GrossPay(hours, rate);
Console.WriteLine("Your gross pay is {0:C}", weeklyGross);
double socialsec = SocialSecurity(weeklyGross);
Console.WriteLine("Your SS deduction is {0:C}", socialsec);
}//end Display
double GrossPay(double weeklyHours, double hourlyRate)
{
double gross =0;
if (weeklyHours > 40)
{
gross = hourlyRate * (40 + ((weeklyHours - 40) * 1.5));
}
else
{
gross = hourlyRate * weeklyHours;
}
return gross;
}//end GrossPay
private void PauseIt()
{
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}//end PauseIt
private double SocialSecurity(double grossWeeklyPay)
{
return grossWeeklyPay * SOCSEC;
}
}//end Program
}//end namespace
No comments:
Post a Comment