As Wes says, most of the problems are due to a little over-enthusiastic use of semicolons!
The semicolon in C# is a statement terminator, so placing it before an open curly bracket is never going to give you what you expect! :laugh:
In addition, you have some odd brackets relating to your CalcNet method:
static void CalcNet();
{
if (hours > 40)
{
gross = Math.Round((hours - 40) * rate * 1.5 + rate * 40,2);
}
else
{
gross = Math.Round(hours*rate,2);
}
}
{
depCost = Math.Round(numOfDep*25.50,2);
tax = Math.Round((gross-depCost)*.23,2);
net = Math.Round(gross-depCost-tax);
}
It's possible that you meant the second section to be a separate method altogether:
static void CalcNet();
{
if (hours > 40)
{
gross = Math.Round((hours - 40) * rate * 1.5 + rate * 40,2);
}
else
{
gross = Math.Round(hours*rate,2);
}
}
static void AnotherMethodAlltogether()
{
depCost = Math.Round(numOfDep*25.50,2);
tax = Math.Round((gross-depCost)*.23,2);
net = Math.Round(gross-depCost-tax);
}
Or you just made a mistake and it should be:
public static void CalcNet()
{
if (hours > 40)
{
gross = Math.Round((hours - 40) * rate * 1.5 + rate * 40,2);
}
else
{
gross = Math.Round(hours*rate,2);
}
depCost = Math.Round(numOfDep*25.50,2);
tax = Math.Round((gross-depCost)*.23,2);
net = Math.Round(gross-depCost-tax);
}
I'll assume that latter! :laugh:
Try this:
namespace Program_6
{
public class Program
{
private static double rate, hours, tax, gross, depCost, net;
private static int numOfDep;
static void Main()
{
GetData();
CalcNet();
DspData();
}
public static void GetData()
{
Console.Write("Hours worked: ");
hours=double.Parse(Console.ReadLine());
Console.Write("Hourly rate: ");
rate=double.Parse(Console.ReadLine());
Console.Write("Dependents: ");
numOfDep=Int32.Parse(Console.ReadLine());
}
public static void CalcNet()
{
if (hours > 40)
{
gross = Math.Round((hours - 40) * rate * 1.5 + rate * 40,2);
}
else
{
gross = Math.Round(hours*rate,2);
}
depCost = Math.Round(numOfDep*25.50,2);
tax = Math.Round((gross-depCost)*.23,2);
net = Math.Round(gross-depCost-tax);
}
public static void DspData()
{
Console.WriteLine("Hours Worked:\t\t{0,10}", hours);
Console.WriteLine("Hourly Rate:\t\t{0,10}", rate);
Console.WriteLine("Dependants:\t\t{0,10}", numOfDep);
Console.WriteLine("Gross Pay:\t\t{0,10}", gross);
Console.WriteLine("Deductions:\t\t{0,10}", tax);
Console.WriteLine("\t\t\t-----------");
Console.WriteLine("Net pay:\t\t{0,10}", net);
}
}
}
I can't say it will work, but it should at least compile!