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
345.9k
payroll
Dec 31 2011 1:08 PM
Hey guys, this is the problem
Write a console-based program that prompts the user for
an hourly pay rate and hours worked. Compute gross pay
(hours times pay rate), withholding tax, and net pay (gross
pay minus withholding tax). Withholding tax is computed
as a percentage of gross pay based on the following:
Gross Pay Withholding Percentage
Up to and including 300.00= 10%
300.01 and up = 12%
Thats what i have done
double hPayRate, hWorked, grossPay, wthHoldTax, netPay;
string stringhPayRate, stringhWorked;
Console.WriteLine(" Please enter your hourly pay rate ");
stringhPayRate = Console.ReadLine();
hPayRate = Convert.ToDouble(stringhPayRate);
Console.WriteLine(" Please enter how many hours you worked ");
stringhWorked = Console.ReadLine();
hWorked = Convert.ToDouble(stringhWorked);
grossPay = hPayRate * hWorked;
if (grossPay <= 300.00)
{
wthHoldTax = grossPay * .10;
netPay = grossPay - wthHoldTax;
Console.WriteLine(" Your net pay is {0}", netPay);
}
else if (grossPay >= 300.01)
{
wthHoldTax = grossPay * .12;
netPay = grossPay - wthHoldTax;
Console.WriteLine(" Your net pay is {0}", netPay);
}
Any other cool alternative ways to solve this problem?
Reply
Answers (
4
)
Help with Login Screen C#
payroll gui