pms 3
New Member
Need suggestions to improve this program. -
using System;
-
-
namespace CalculateWage
-
{
-
-
class GetEmployeeDetails
-
{
-
public string LastName, FirstName;
-
-
public int NumberofHours;
-
-
public int WagesforaWeek, HourlyRate;
-
-
public int Medical, UnionFee;
-
-
public int TotalDeduction, FederalTax;
-
-
public int Netpay;
-
-
}
-
-
-
class Wage
-
{
-
-
-
-
static void Main(string[] args)
-
{
-
-
GetEmployeeDetails GED = new GetEmployeeDetails();
-
-
Getinteger I = new Getinteger();
-
-
Getstring S = new Getstring();
-
-
-
GED.FirstName = S.GetString("\nEnter ur First Name: ", "");
-
-
GED.LastName = S.GetString("\nEnter ur Last Name: ", "");
-
-
GED.NumberofHours = I.GetInteger("\nEnter no of hours worked: ", 0);
-
-
GED.HourlyRate = I.GetInteger("\nEnter hourly rate:", 0);
-
-
GED.WagesforaWeek = ((GED.NumberofHours * GED.HourlyRate) * 7);
-
-
-
Console.WriteLine("\nwages for a week:{0}", GED.WagesforaWeek);
-
-
Console.ReadLine();
-
-
-
GED.FederalTax = (GED.WagesforaWeek * (18 / 100));
-
GED.Medical = (GED.WagesforaWeek * (5 / 100));
-
GED.UnionFee = 8;
-
GED.TotalDeduction = (GED.FederalTax + GED.Medical + GED.UnionFee);
-
GED.Netpay = (GED.WagesforaWeek - GED.TotalDeduction);
-
-
-
Console.WriteLine("\nName:{0}", GED.LastName);
-
-
Console.WriteLine("\nThe gross pay of {0} is {1}", GED.LastName, GED.WagesforaWeek);
-
-
Console.WriteLine("\nThe total deduction is:{0}", GED.TotalDeduction);
-
-
Console.WriteLine("\nThe net pay of {0} is: {1}", GED.LastName, GED.Netpay);
-
-
Console.ReadLine();
-
}
-
-
-
-
}
-
}
-
-
-
class Getstring
-
{
-
-
public string GetString(string Prompt, string FirstName)
-
{
-
-
Console.Write(Prompt);
-
-
-
FirstName = (Console.ReadLine());
-
-
if (Regex.IsMatch(FirstName, "^[a-zA-Z'.]{1,40}$"))
-
{
-
}
-
else
-
{
-
Console.WriteLine("\nThe input should be a string!");
-
-
Console.Write(Prompt);
-
-
FirstName = (Console.ReadLine());
-
-
if (Regex.IsMatch(FirstName, "^[a-zA-Z'.]{1,40}$"))
-
{
-
}
-
else
-
{
-
Console.WriteLine("\nYou entered invalid input twice. The program will terminate");
-
-
System.Threading.Thread.Sleep(3000);
-
-
System.Diagnostics.Process.GetCurrentProcess().Kill();
-
-
}
-
}
-
-
-
-
return FirstName;
-
}
-
-
-
}
-
-
-
-
-
-
-
public class Getinteger
-
{
-
-
public int GetInteger(string Prompt, int num1)
-
{
-
-
Console.Write(Prompt);
-
-
num1++;
-
-
try
-
{
-
num1 = int.Parse(Console.ReadLine());
-
-
if (num1 < 0)
-
{
-
Console.WriteLine("\nEnter +ve number");
-
-
Console.Read();
-
-
if (num1 < 2)
-
{
-
num1 = GetInteger(Prompt, num1);
-
-
return num1;
-
}
-
else
-
{
-
Console.WriteLine("\nYou entered invalid input twice. The program will terminate");
-
-
System.Threading.Thread.Sleep(3000);
-
-
System.Diagnostics.Process.GetCurrentProcess().Kill();
-
}
-
}
-
}
-
-
catch
-
{
-
-
Console.WriteLine("\nThe input should be an integer!");
-
-
-
if (num1 < 2)
-
{
-
num1 = GetInteger(Prompt, num1);
-
}
-
else
-
{
-
Console.WriteLine("You entered invalid input twice. The program will terminate");
-
-
System.Threading.Thread.Sleep(3000);
-
-
System.Diagnostics.Process.GetCurrentProcess().Kill();
-
}
-
}
-
-
return num1;
-
}
-
-
}
-
4 1255 pms 3
New Member - using System;
-
using System.Collections.Generic;
-
using System.Text;
-
using System.Configuration.Assemblies;
-
-
-
-
namespace CalculateWage
-
{
-
-
class GetEmployeeDetails
-
{
-
public string LastName, FirstName;
-
-
public int NumberofHours;
-
-
public int WagesforaWeek, HourlyRate;
-
-
public int Medical, UnionFee;
-
-
public int TotalDeduction, FederalTax;
-
-
public int Netpay;
-
-
}
-
-
-
class Wage
-
{
-
-
-
-
static void Main(string[] args)
-
{
-
-
GetEmployeeDetails GED = new GetEmployeeDetails();
-
-
Getinteger I = new Getinteger();
-
-
Getstring S = new Getstring();
-
-
-
GED.FirstName = S.GetString("\nEnter ur First Name: ", "");
-
-
GED.LastName = S.GetString("\nEnter ur Last Name: ", "");
-
-
GED.NumberofHours = I.GetInteger("\nEnter no of hours worked: ", 0);
-
-
GED.HourlyRate = I.GetInteger("\nEnter hourly rate:", 0);
-
-
GED.WagesforaWeek = ((GED.NumberofHours * GED.HourlyRate) * 7);
-
-
-
Console.WriteLine("\nwages for a week:{0}", GED.WagesforaWeek);
-
-
Console.ReadLine();
-
-
-
GED.FederalTax = (GED.WagesforaWeek * (18 / 100));
-
GED.Medical = (GED.WagesforaWeek * (5 / 100));
-
GED.UnionFee = 8;
-
GED.TotalDeduction = (GED.FederalTax + GED.Medical + GED.UnionFee);
-
GED.Netpay = (GED.WagesforaWeek - GED.TotalDeduction);
-
-
-
Console.WriteLine("\nName:{0}", GED.LastName);
-
-
Console.WriteLine("\nThe gross pay of {0} is {1}", GED.LastName, GED.WagesforaWeek);
-
-
Console.WriteLine("\nThe total deduction is:{0}", GED.TotalDeduction);
-
-
Console.WriteLine("\nThe net pay of {0} is: {1}", GED.LastName, GED.Netpay);
-
-
Console.ReadLine();
-
}
-
-
-
-
}
-
}
-
-
-
-
-
-
-
-
using System;
-
using System.Collections.Generic;
-
using System.Text;
-
using System.Configuration.Assemblies;
-
-
-
-
namespace CalculateWage
-
{
-
-
class GetEmployeeDetails
-
{
-
public string LastName, FirstName;
-
-
public int NumberofHours;
-
-
public int WagesforaWeek, HourlyRate;
-
-
public int Medical, UnionFee;
-
-
public int TotalDeduction, FederalTax;
-
-
public int Netpay;
-
-
}
-
-
-
class Wage
-
{
-
-
-
-
static void Main(string[] args)
-
{
-
-
GetEmployeeDetails GED = new GetEmployeeDetails();
-
-
Getinteger I = new Getinteger();
-
-
Getstring S = new Getstring();
-
-
-
GED.FirstName = S.GetString("\nEnter ur First Name: ", "");
-
-
GED.LastName = S.GetString("\nEnter ur Last Name: ", "");
-
-
GED.NumberofHours = I.GetInteger("\nEnter no of hours worked: ", 0);
-
-
GED.HourlyRate = I.GetInteger("\nEnter hourly rate:", 0);
-
-
GED.WagesforaWeek = ((GED.NumberofHours * GED.HourlyRate) * 7);
-
-
-
Console.WriteLine("\nwages for a week:{0}", GED.WagesforaWeek);
-
-
Console.ReadLine();
-
-
-
GED.FederalTax = (GED.WagesforaWeek * (18 / 100));
-
GED.Medical = (GED.WagesforaWeek * (5 / 100));
-
GED.UnionFee = 8;
-
GED.TotalDeduction = (GED.FederalTax + GED.Medical + GED.UnionFee);
-
GED.Netpay = (GED.WagesforaWeek - GED.TotalDeduction);
-
-
-
Console.WriteLine("\nName:{0}", GED.LastName);
-
-
Console.WriteLine("\nThe gross pay of {0} is {1}", GED.LastName, GED.WagesforaWeek);
-
-
Console.WriteLine("\nThe total deduction is:{0}", GED.TotalDeduction);
-
-
Console.WriteLine("\nThe net pay of {0} is: {1}", GED.LastName, GED.Netpay);
-
-
Console.ReadLine();
-
}
-
-
-
-
}
-
}
-
class Getstring
-
{
-
-
public string GetString(string Prompt, string FirstName)
-
{
-
-
Console.Write(Prompt);
-
-
-
FirstName = (Console.ReadLine());
-
-
if (Regex.IsMatch(FirstName, "^[a-zA-Z'.]{1,40}$"))
-
{
-
}
-
else
-
{
-
Console.WriteLine("\nThe input should be a string!");
-
-
Console.Write(Prompt);
-
-
FirstName = (Console.ReadLine());
-
-
if (Regex.IsMatch(FirstName, "^[a-zA-Z'.]{1,40}$"))
-
{
-
}
-
else
-
{
-
Console.WriteLine("\nYou entered invalid input twice. The program will terminate");
-
-
System.Threading.Thread.Sleep(3000);
-
-
System.Diagnostics.Process.GetCurrentProcess().Kill();
-
-
}
-
}
-
-
-
-
return FirstName;
-
}
-
-
-
}
-
-
-
-
public class Getinteger
-
{
-
-
public int GetInteger(string Prompt, int num1)
-
{
-
-
Console.Write(Prompt);
-
-
num1++;
-
-
try
-
{
-
num1 = int.Parse(Console.ReadLine());
-
-
if (num1 < 0)
-
{
-
Console.WriteLine("\nEnter +ve number");
-
-
Console.Read();
-
-
if (num1 < 2)
-
{
-
num1 = GetInteger(Prompt, num1);
-
-
return num1;
-
}
-
else
-
{
-
Console.WriteLine("\nYou entered invalid input twice. The program will terminate");
-
-
System.Threading.Thread.Sleep(3000);
-
-
System.Diagnostics.Process.GetCurrentProcess().Kill();
-
}
-
}
-
}
-
-
catch
-
{
-
-
Console.WriteLine("\nThe input should be an integer!");
-
-
-
if (num1 < 2)
-
{
-
num1 = GetInteger(Prompt, num1);
-
}
-
else
-
{
-
Console.WriteLine("You entered invalid input twice. The program will terminate");
-
-
System.Threading.Thread.Sleep(3000);
-
-
System.Diagnostics.Process.GetCurrentProcess().Kill();
-
}
-
}
-
-
return num1;
-
}
-
-
}
sicarie 4,677
Recognized Expert Moderator Specialist pms 3
New Member
Moved to C# forum.
couldn't get ur reply
Please don't repost your questions, it is against site rules. This isn't really the place to optimize your code. If you have a problem or error post that and we will have a look. Thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: ben |
last post by:
i have a bit of code, that works absolutely fine as is, but seems over
complicated/long winded. is there anyway to shorten/simplify it?
the code is below. description of it: it's like strcpy in...
|
by: Nedu N |
last post by:
Hi,
I want to have confirmation(Yes/No) on a button of the webform in which
there are many validation controls. I want all the validation controls to be
triggered first and then Yes/No...
|
by: pv |
last post by:
Hi everyone,
I need help with following scenario, please:
Users are accessing same web server from intranet (users previously
authenticated in Active Dir) and from extranet (common public...
|
by: csharpwanderer |
last post by:
Hello,
I am spending too much time trying to sort out what I think should be simple. So here it is.
I have a wizard, with five steps.
<wizard1>
<wizardstep1><componant1></wizardstep1>...
|
by: davidkoree |
last post by:
I mean not about cookie.
Does it have something to do with operating system or browser plugin?
I appreciate any help.
| |
by: sudhashekhar30 |
last post by:
hi all
i have textbox in step in wizard control(step-10). there are 10 steps. so i want validation on every page and user can't move to other step without completing all correct entry. when i...
|
by: tshad |
last post by:
I have dataGrid that I am filling from a List Collection and need to sort it
by the various columns.
So I need to be able to sort the Collection and found that you have to set
up your own...
|
by: slapsh0t11 |
last post by:
Hello! I need help with a program that I believe I am nearly done with. However, there seems to be a few details that preclude me from success. Here is my assignment:
Here is my class file...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |