Create a console-based application named
ComputeWeeklySalary. Include two overloaded methods—
one that accepts an annual salary as an integer
and one that accepts an annual salary as a double. Each
method should calculate and display a weekly salary,
assuming 52 weeks in a year. Include a Main() method
that demonstrates both overloaded methods work correctly.
you think this solves the problem?
double annualSalary=0;
AnnualSalary(ref annualSalary);
}
public static void AnnualSalary(ref int annSalary)
{
Console.WriteLine("Please enter your hourly pay rate ");
int hrlPayRate = Convert.ToInt32(Console.ReadLine());
const int days = 5;
const int weeks = 52;
int total;
total = days * hrlPayRate;
annSalary = total * weeks;
Console.WriteLine("Assuming you work 5 days per week you make {0}, and your annual salary is {1}", total,annSalary);
}
public static void AnnualSalary(ref double annSalary)
{
Console.WriteLine("Please enter your hourly pay rate ");
double hrlPayRate = Convert.ToDouble(Console.ReadLine());
const double days = 5;
const double weeks = 52;
double total;
total = days * hrlPayRate;
annSalary = total * weeks;
Console.WriteLine("Assuming you work 5 days per week you make {0}, and your annual salary is {1}", total, annSalary);
}
Loading
VulpesPosted Jan 16, 2012, 4:51 AM
http://www.c-sharpcorner.com/Forums/Thread/157458/another-problem-with-methods.aspx
However, you have another issue here in that you appear to be making the calculations unnecessarily complicated - all that's needed is to divide the annual salary by 52.
I'd suggest:
Prime bPosted Jan 16, 2012, 11:57 AM