I'm New to programming..
using System;//prompt for the hourly rate, hours worked,& single or married status.
//Also, a validation of some sort to verify the marital status, if not valid display an invalid
//Then, it should calulate gross and net pay Married will apply 15% single will apply 22%
public class ComputeTaxFor5Employees
{
public static void Main()
{
double hourlyRate,hours, grosspay;
char status;
string Employee;
//needs a for loop to execute for 5 people
Console.WriteLine("Enter hourly pay rate for employee: ");
Console.WriteLine();
Employee= Console.ReadLine();
hours= Convert.ToDouble(Employee);
Console.WriteLine("Enter hours worked for employees: ");
Console.WriteLine();
Employee= Console.ReadLine();
hours= Convert.ToDouble(Employee);
grossPay= GrossPay(hourlyRate, hours);
Console.WriteLine("Gross pay earned by employee is {0}", "GrossPay");
Console.WriteLine("Press enter to continue");
Console.ReadLine();
}
public static double GrossPay(double hourlyRate, double hours)
{
double GrossPay;
GrossPay= hourlyRate * hours;
return GrossPay;
}
}
Can anyone help me out with this program? on completing it?
public class ComputeTaxFor5Employees{ public static void Main() { double hourlyRate,hours, grosspay; char status; string Employee;// Start of loop for( int i = 0; i < 5; i++ ) { Console.WriteLine("Enter hourly pay rate for employee: "); Console.WriteLine(); Employee= Console.ReadLine(); hours= Convert.ToDouble(Employee); Console.WriteLine("Enter hours worked for employees: "); Console.WriteLine(); Employee = Console.ReadLine(); hours = Convert.ToDouble(Employee); grossPay = GrossPay(hourlyRate, hours); Console.WriteLine("Gross pay earned by employee is {0}", "GrossPay"); Console.WriteLine("Press enter to continue"); Console.ReadLine(); }// End of loop } public static double GrossPay(double hourlyRate, double hours) { double GrossPay; GrossPay = hourlyRate * hours; return GrossPay; }}
I only added the loop. Hope it works.
0) Try asking a more specific question. What doesn't seem to be working? What do you feel is missing from the functionality? Separate your question from the code, and phrase it as an actual question at the beginning of your post. See also this guide to asking questions.
1) As a matter of common courtesy, indicate the language your code is in. I assume C# based on what it looks like, but these kinds of guesses can be wrong.
2) Code goes between [code][/code] tags for short blocks, and [source][/source] tags for longer blocks. This is described in detail in the Forum FAQ that is linked at the top of every forum page.
3) If you are "new to programming", you should be posting in For Beginners. It is appropriately named, and appears first in the forum listings - it should be hard to miss.
1) As a matter of common courtesy, indicate the language your code is in. I assume C# based on what it looks like, but these kinds of guesses can be wrong.
2) Code goes between [code][/code] tags for short blocks, and [source][/source] tags for longer blocks. This is described in detail in the Forum FAQ that is linked at the top of every forum page.
3) If you are "new to programming", you should be posting in For Beginners. It is appropriately named, and appears first in the forum listings - it should be hard to miss.
Thanks, I'll remember that next time. I was in a hurry yesterday cause it was a group lab that was due. Don't worry, I can seek outside help.
I still get a warning from the grosspay just before the end of the loop.
using System;public class ComputeTaxFor5Employees{ public static void Main() { double hourlyRate,hours, grosspay; char status; string Employee;// Start of loop for( int i = 0; i < 5; i++ ) { Console.WriteLine("Enter hourly pay rate for employee: "); Console.WriteLine(); Employee= Console.ReadLine(); hours= Convert.ToDouble(Employee); Console.WriteLine("Enter hours worked for employees: "); Console.WriteLine(); Employee = Console.ReadLine(); hours = Convert.ToDouble(Employee); grossPay = GrossPay(hourlyRate, hours); Console.WriteLine("Gross pay earned by employee is {0}", "GrossPay"); Console.WriteLine("Press enter to continue"); Console.ReadLine(); }// End of loop } public static double GrossPay(double hourlyRate, double hours) { double GrossPay; GrossPay = hourlyRate * hours; return GrossPay; }}
I still get a warning from the grosspay just before the end of the loop.
double hourlyRate,hours, grosspay;...grossPay= GrossPay(hourlyRate, hours);
C# is case-sensitive. Fix your names.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement