C# function for sort

csharp , functiom , sort Pécs, Hungary
  • 12 years ago
    i need a program than can be ask user : name , age , id , and salary then shows me the maximum salary and minimum salary and then sort salary from maximum to minimum . please complete these program for me Code: public string name;a public int age; public bool ID; private int salary; public void Staff() { Console.WriteLine("enter your name"); name = Console.ReadLine(); Console.WriteLine("enter your age : "); age = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("enter your ID:"); ID = Console.ReadLine(); Console.WriteLine("enter your salary:"); income = Convert.ToInt32(Console.ReadLine()); }
  • 12 years ago
    i have write some codes but it dose not work yet please complete it for me [CODE]using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication58 { struct Salary { string name; int age; int ID; int salary; void Staff() { Console.WriteLine("enter your name"); name = Console.ReadLine(); Console.WriteLine("enter your age : "); age = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("enter your ID:"); ID = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("enter your salary:"); salary = Convert.ToInt32(Console.ReadLine()); } List Humans = new List(); } void Add(Int16 humanID, string humanName, Int16 humanAge, float humanSalary) { Humans.Add(new Human(humanID, humanName, humanAge, humanSalary)); } float GetMaxSalary() { float maxSalary = 0; foreach (Human aHuman in Humans.ToArray()) { if (aHuman.SALARY > maxSalary) maxSalary = aHuman.SALARY; } return maxSalary; } float GetMinSalary() { float minSalary = GetMaxSalary(); foreach (Human aHuman in Humans.ToArray()) { if (aHuman.SALARY < minSalary) minSalary = aHuman.SALARY; } return minSalary; } float GetAverage() { float totalSalary = 0; foreach (Human aHuman in Humans.ToArray()) { totalSalary += aHuman.SALARY; } return totalSalary / Humans.Count; } } struct Human { public Int16 ID; public string NAME; public Int16 AGE; public float SALARY; public Human(Int16 humanID, string humanName, Int16 humanAge, float humanSalary) { ID = humanID; NAME = humanName; AGE = humanAge; SALARY = humanSalary; } } }[/CODE]

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” - Donald Knuth