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

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());

}

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.

Edited 3 Years Ago by Dani: Formatting fixed

We will give you bricks, wood, mortar, any other materials if needed.
We will not build your house.

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.

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

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

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication54
{
    struct human
    {

        public string name;
        public int age;
        public int 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 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter your salary:");
            salary = Convert.ToInt32(Console.ReadLine());
        }



        class Program
        {
            static void Main(string[] args)
            {
                string[] cArray = new string[5] { "Cha3123", "Cha1234", "Cha1243", "Cha34", "Cha53" };
                Array.Sort(cArray, StringComparer);
                foreach (string s in cArray)
                {
                    Console.WriteLine(s);
                }
                Console.ReadLine();
            }
            static int StringComparer(object a, object b)
            {
                int stra = Convert.ToInt32((a as string).Remove(0, 3));
                int strb = Convert.ToInt32((b as string).Remove(0, 3));
                return stra - strb;
            }
        }
    }
}

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

No, it sorted the numbers as you told it to - or at least it did when I ran it.

i want to it show me the max and min salary and the sort number after i gave it to program not the character are in the this line

string[] cArray = new string[3] { "Cha3123", "Cha1234", "Cha1243" };

------------
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication54
{
struct Salary
{

public string name;
public int age;
public int 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 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter your salary:");
salary = Convert.ToInt32(Console.ReadLine());
}

class Program
{
static void Main(string[] args)
{
string[] cArray = new string[3] { "Cha3123", "Cha1234", "Cha1243" };
Array.Sort(cArray, StringComparer);
foreach (string s in cArray)
{
Console.WriteLine(s);
}
Console.ReadLine();
}
static int StringComparer(object a, object b)
{
int stra = Convert.ToInt32((a as string).Remove(0, 3));
int strb = Convert.ToInt32((b as string).Remove(0, 3));
return stra - strb;
}
}
}
}

namespace ConsoleApplication54

Seems to me you have tried already something out!
But you look like a blind man who is trying to break an egg with a stick!
So first things first : forget for a moment your end result.
Concentrate on making a struct :

struct human
{
    string name;
    int age;
    bool ID;
    int salary;
}

Make a program with only the struct. Does it compile? Does it run?
Find out what a struct is Google, MSDN, books you have, Help menu.
If you done all that try to go a step further, if you are stuck come back.

i want to it show me the max and min salary and the sort number after i gave it to program not the character are in the this line

string[] cArray = new string[3] { "Cha3123", "Cha1234", "Cha1243" };

Well your code only dumps out the values in the array, if you wish for min and max then you would have to add the code for that.. But

It printed them out in numerical order for me when I ran your code

Which is exactly what you told it to.
If you wish it to do so *AFTER* you have entered some data, change your code to ask for some data, and store it, and then run the sort.

Concentrate on making a struct :

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication54
{
 
        struct salary
        {
        string name;
       int age;
        int ID;
        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 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter your salary:");
            salary = Convert.ToInt32(Console.ReadLine());
        }

        class array
        {
            public int useff (string array )
            {
                string[] cArray = new string[3] { "Cha3123", "Cha1234", "Cha1243" };
                Array.Sort(cArray, StringComparer);
                foreach (string s in cArray)
                {
                    Console.WriteLine(s);
                }
                Console.ReadLine();
            }
            static int StringComparer(object a, object b)
            {
                int stra = Convert.ToInt32((a as string).Remove(0, 3));
                int strb = Convert.ToInt32((b as string).Remove(0, 3));
                return stra - strb;
            }

        }
        class Program
        {
            static void Main(string[] args)
            {

                Salary m1 = new Salary();




            }
        }
    }

}

well, seems you don't need to try we've absolved responsibility regards this, I'll try it after some minutes and come back with C# code.

Here's some codes...

List<Human> Humans = new List<Human>();

        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;
        }
    }
Comments
Does things very well!

Yes , i don't have 3.5 and it's 2
my visual studio is 2005 .

any way i can't run these codes yet ...

?! I've did for you almost all functions your program should do. Just try to make use of them and have a deep look inside the code to learn how things done.

can you please trace you first line ?
List<Human> Humans = new List<Human>();

Part of the problem of hand feeding people code is they then dont understand it.

I know, and yet despite your code they write back with

can you please trace you first line ?
List<Human> Humans = new List<Human>();

Eg, they didnt get it.

sorry for my discommodity

but i really can't run it

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication54
{
struct salary
{
string name;
int age;
int ID;
int salary;
}
class program
{
public void human()
{
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<Human> Humans = new List<Human>();
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;
}
}
}

Edited 3 Years Ago by pritaeas: Fixed formatting

Why not? you fail to mention any compile errors or runtime errors..
Firstly Im guessing it doesnt compile because theres no Main function any more
Secondly, I dont believe he (assumption, sorry) actually said it was a 100% program, it was "some code" to demonstrate things.
Thus showing me, you just blindly cut and paste and have no idea whats going on..

:(

I think going on replying this post is just wasting time! really.
Please read in basic C# programming, It's definitely impossible to ask someone has no idea about math and ask him to solve an equation.
I can't try with you again else you show readiness to start on your own.

You can't run your code because there isn't a main method.

After looking up 2 web sites, you most likely won't find people to do your homework for you.

You need to slow down, and go learn about the C# language. Copying and pasting some program from somewhere and looking on the internet for people to do your homework isn't going to help you.

This is a very easy program also. Read just a bit about arrays and sorting and it's simple. :)

You can't run your code because there isn't a main method.

After looking up 2 web sites, you most likely won't find people to do your homework for you.

You need to slow down, and go learn about the C# language. Copying and pasting some program from somewhere and looking on the internet for people to do your homework isn't going to help you.

This is a very easy program also. Read just a bit about arrays and sorting and it's simple. :)

ok i'm accept with you too
but please believe me and i really need this program . i really need as critical and this is not my homework. please complete this program for me and in next time i will be work hard with c# . i'm amatur not professional

This article has been dead for over six months. Start a new discussion instead.