Doing a college project and I'm a bit stuck..
Basically, I need to take the string input for an employee name and an integer input for the amount of properties they sold.
I then need to print these values in descending order based on the number of properties sold, so, for example, I need to print something like this:
(Bolded to make it easier to read)
Name: John Properties Sold: 5
Name: Peter Properties Sold: 4
Name: Craig Properties Sold: 3
I have stored the name and properties sold in their own separate lists, I know how to sort the number list in size order but then how do I link it back with the appropriate name?
List<string> names = new List<string>();
List<int> numbers = new List<int>();
for(int i = 0; i < 2; i++){
Console.WriteLine("Please enter the employee name: ");
names.Add(Console.ReadLine());
Console.WriteLine("Please enter the number of Properties Sold: ");
numbers.Add(int.Parse(Console.ReadLine()));
}
numbers.Sort();
numbers.Reverse();
foreach(int i in numbers){
Console.WriteLine(i);
}
Any help is appreciated, I am not the best coder so sorry if I'm asking a dumb question.
ToString()
), inherit a base class (Realtor
may inheritEmployee
as a base class), or implement an interface; in which caseTuple
andDictionary
no longer make sense. Just something to think about.