TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prime b
NA
810
346k
Method overload
Jan 15 2012 7:39 PM
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);
}
Reply
Answers (
2
)
Another problem with methods
Method help