//my code almost does everything i want the only thing i am trying to achieve is that i want to calculate the payrate and print the results for example if the user inputs more than 40 hours i want it to show overtime but its not working and another thing im trying to achieve is for my program to ask all the questions first and then print the results BUT it asks the first question and then prints the first question result, the same happens for the second question.......any help would be so appreciated.
class Person
{protected string name, segsoc;//i CANNOT change anything in this class
//Constructor
//Does not recieve data to create the person
//puts default data
public Person()
{
name =
"";
segsoc =
Console.WriteLine("Person constructed.");
}
//Destroyer
~Person()
Console.WriteLine("Person destroyed.");
class Employee : Person//In this class i can ONLY have 2 METHODS but i can decalre
//all the propeties and variables i need.
private double p, hrs, final;
private string theName, segs;
public Employee()
Console.Write("Employee constructed.");
public string name
set
theName =
value;
get
Console.Write("Please Enter your name: ");
Console.ReadLine();
return theName;
public string segsoc
segs =
Console.Write("Please Enter your Social Security: ");
return segs;
public double pay
p =
Console.Write("Please Enter your payrate: ");
double.Parse(Console.ReadLine());
return p;
public double hours
hrs =
Console.Write("Please Enter the number of hours you worked: ");
return hrs;
public double fin//this property does not calcualate what i want. The final result is 0 when i execute the program
final =
if (hrs > 0 || hrs <= 40)
final = final * pay;
else if (hours > 40)
Console.WriteLine("You get payed double for overtime!");
final = final * (pay * 2.0);
else
do
Console.Write("Please valid hours!");
while (hrs < 0);
return final;
~Employee()
Console.WriteLine("Employee destroyed.");
static void Main(string[] args)//i want main to print all the information the user input
Employee worker = new Employee();
Console.WriteLine("\n\n===Employee Information===");
Console.WriteLine("\nName : " + worker.name);//this prints but it prints right after you enter it
Console.WriteLine("Social Security: " + worker.segsoc);//this prints but right after you enter it.
Console.WriteLine("Payrate : " + worker.p);
Console.WriteLine("Hours : " + worker.hrs);
Console.WriteLine("Pay : " + worker.fin);
Console.WriteLine("\n==========================");