C# function for sort

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 12
Reputation: drfarzad is an unknown quantity at this point 
Solved Threads: 0
drfarzad drfarzad is offline Offline
Newbie Poster

C# function for sort

 
0
  #1
Dec 31st, 2008
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
  1. public string name;a
  2. public int age;
  3. public bool ID;
  4. private int salary;
  5. public void Staff()
  6. {
  7. Console.WriteLine("enter your name");
  8. name = Console.ReadLine();
  9. Console.WriteLine("enter your age : ");
  10. age = Convert.ToInt32(Console.ReadLine());
  11. Console.WriteLine("enter your ID:");
  12. ID = Console.ReadLine();
  13. Console.WriteLine("enter your salary:");
  14. income = Convert.ToInt32(Console.ReadLine());
}
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: C# function for sort

 
0
  #2
Dec 31st, 2008
You can read either in LINQ or ArrayList, in your case I prefer to read in ArrayList.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,930
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 276
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: C# function for sort

 
0
  #3
Dec 31st, 2008
Make a struct from your data :
struct Employee
{
string name;
public int age;
public bool ID;
private int salary;
}
Now make an ArrayList of Employee as RamyMahrous pointed out.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 12
Reputation: drfarzad is an unknown quantity at this point 
Solved Threads: 0
drfarzad drfarzad is offline Offline
Newbie Poster

Re: C# function for sort

 
0
  #4
Dec 31st, 2008
can you please complete this issue for me ?
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,930
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 276
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: C# function for sort

 
0
  #5
Dec 31st, 2008
We will give you bricks, wood, mortar, any other materials if needed.
We will not build your house.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: C# function for sort

 
0
  #6
Dec 31st, 2008
Give us hint you tried, if you declare instance from ArrayList class and pressed '.' you'll find someone much greater than us with all respect to my friend Ddanbe. it's intellisense and documentation.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: C# function for sort

 
0
  #7
Dec 31st, 2008
have a look in the helpfile as to try, and then show us your code, and the errors and/or explain in what way it hadnt done what you wanted..

Then we will help
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 12
Reputation: drfarzad is an unknown quantity at this point 
Solved Threads: 0
drfarzad drfarzad is offline Offline
Newbie Poster

Re: C# function for sort

 
0
  #8
Dec 31st, 2008
this is my confused program and it dose not as well . it sort some of character from min to max but i want to it sort my salary after the program gives me the salary number

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace ConsoleApplication54
  6. {
  7. struct human
  8. {
  9.  
  10. public string name;
  11. public int age;
  12. public int ID;
  13. private int salary;
  14. public void Staff()
  15. {
  16. Console.WriteLine("enter your name");
  17. name = Console.ReadLine();
  18. Console.WriteLine("enter your age : ");
  19. age = Convert.ToInt32(Console.ReadLine());
  20. Console.WriteLine("enter your ID:");
  21. ID = Convert.ToInt32(Console.ReadLine());
  22. Console.WriteLine("enter your salary:");
  23. salary = Convert.ToInt32(Console.ReadLine());
  24. }
  25.  
  26.  
  27.  
  28. class Program
  29. {
  30. static void Main(string[] args)
  31. {
  32. string[] cArray = new string[5] { "Cha3123", "Cha1234", "Cha1243", "Cha34", "Cha53" };
  33. Array.Sort(cArray, StringComparer);
  34. foreach (string s in cArray)
  35. {
  36. Console.WriteLine(s);
  37. }
  38. Console.ReadLine();
  39. }
  40. static int StringComparer(object a, object b)
  41. {
  42. int stra = Convert.ToInt32((a as string).Remove(0, 3));
  43. int strb = Convert.ToInt32((b as string).Remove(0, 3));
  44. return stra - strb;
  45. }
  46. }
  47. }
  48. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: C# function for sort

 
0
  #9
Dec 31st, 2008
What's this??
You need to read in Structures as well.
Let us start.
1- I need you do initialize an array of 5 elements from human datatype
Last edited by Ramy Mahrous; Dec 31st, 2008 at 8:57 am.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: C# function for sort

 
0
  #10
Dec 31st, 2008
No, it sorted the numbers as you told it to - or at least it did when I ran it.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC