I am new to programming and got stuck on an assignment.
The assignment is to input name, age and number of sales for 4 different workers. After that I need to post the workers in order based on their amount of sales.
Where I am mostly stuck is the loop-part. I do not understand how I can insert values to the 4 workers and then return their values in order.
int pay = 1000;
Console.WriteLine("What is the first- and lastname of the worker: ");
string name = Convert.ToString(Console.ReadLine());
Console.WriteLine("What is the age of the worker: ");
int age = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("What district does the worker work at: ");
string district = Convert.ToString(Console.ReadLine());
Console.WriteLine("How many sales has the worker done: ");
int sales = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("\n");
Console.WriteLine("Name\t\tAge\tDistrict\tSales");
Console.WriteLine(name + "\t" + age + "\t" + district + "\t\t" + sales);
Console.WriteLine("\n");
if (sales > 199)
{
pay = pay + sales * 4;
Console.WriteLine(name + " is level 4 \nand will get: " + pay + "kr this month");
}
else if (sales <= 199 && sales >= 100)
{
pay = pay + sales * 3;
Console.WriteLine(name + " is level 3 \nand will get: " + pay + "kr this month");
}
else if (sales <= 99 && sales >= 50)
{
pay = pay + sales * 2;
Console.WriteLine(name + " is level 2 \nand will get: " + pay + "kr this month");
}
else
{
pay = pay + sales;
Console.WriteLine(name + " is level 1\nand will get: " + pay + "kr this month");
}
~ Please excuse the mess, I have yet to learn the proper structure of coding.