Since you pasted the image instead of text, we have to pay for it by re-typing.
Do not handover like this. Instead of trying to employ design patterns (which is not expected from you), handover work which is correct.
Your assignment says that you should take as input the employee name, employee type and years of experience.
Your console app should get these three values by Console.ReadLine()
commands.
Please make sure that this is so. Bu it probably is, since all the code competitions use stdin (Console.ReadLine() reads from stdin
) to feed input to an application.
Then, what your teacher wants from you are:
- Generate a sequential employee Id,
- Calculate the salary according to the years of experience
- Print out the results (using
Console.WriteLine()
, which writes to the stdout (standard output))
- Proceed to the next employee
Here is a limited example to help you. Please do research and fill in the required parts yourself, otherwise, what does it mean to get a good mark if it isn't yours?
I am not saying that you can handover this directly, mind you.
But at least you can take this as a starting point.
Good luck.
static void Main()
{
// this will be used to create sequential employee Ids
int employeeId = 0;
while(true) // Just press enter without entering anything to exit.
{
string employeeName = Console.ReadLine();
if(employeeName == "")
{
return;
}
// Get the other two input parameters like the one above.
// Please be careful with the last one (years of experience)
// It should be parsed to an integer (a little research effort)
// string employeeType = ..
// int yearsOfExperience = ..
// Now, assign this employee the next Id.
employeeId++;
// And now, calculate the employee's salary
// You should use the years of experience and employee type
// to match an amount in the salary table.
int salary;
if(employeeType == "Permanent")
{
salary = ..;
}
else
{
salary = ..;
}
// And finally, print-out using stdout
Console.WriteLine("Employee ID: {0}", employeeId);
// Print the other two outputs like the one above
}
}