What's new
  • Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

Solved C# C# codes using arrays.. paano po makuha ung Employee with Net Pay.. "NAME"


m0stwanted143

Honorary Poster
if galing database yan, I usually use entity framework.. tapos iso-sort sa highest ang netpay.. tapos display nalang.. :D
Hehe di ko alam boss yung Sinasabi nyu 😅😅 pero thanks po sa info. Meron po kc akong code pero ung name nlng po ang di ko makuha .
 
Comment

m0stwanted143

Honorary Poster
show mo daw code.
string dec = "YES";
while (dec.ToUpper() == "YES")


Console.Write("NumberofCustomer"); size=Convert.ToInt32(Console.ReadLine());
Console.clear();
string[] name = new string[size];
double[] gp= new double[size];
double[] td = new double[size];
double [] NP= new double [size];
double max= 0;

For (int i = 0; i < size; i++)
{
Console.Write("Input Name: ");
narae = Console.ReadLine();
Console.Write( "Total Deduction: ");
td=Convert.ToDouble(Console.ReadLine());
NP = gp - td;
Console.Write("Netpay:" + NP);
if (max <NP)
{
max = NP;
}
}
Console.Write("NAME\t GROSSPAY\t TOTALDEDUCTION\t NETPAY");
for(i=0; i < size; i++)
{
Console.WriteLine(name+ "\t" + gp + "\t" + td + "\t" + NP);
}
Console.ReadLine();


Console.write("do u want to continue yes/no ");
dec = Console.ReadLine();
Console.Clear();
 
Comment

vespine

Honorary Poster
string dec = "YES";
while (dec.ToUpper() == "YES")


Console.Write("NumberofCustomer"); size=Convert.ToInt32(Console.ReadLine());
Console.clear();
string[] name = new string[size];
double[] gp= new double[size];
double[] td = new double[size];
double [] NP= new double [size];
double max= 0;

For (int i = 0; i < size; i++)
{
Console.Write("Input Name: ");
narae = Console.ReadLine();
Console.Write( "Total Deduction: ");
td=Convert.ToDouble(Console.ReadLine());
NP = gp - td;
Console.Write("Netpay:" + NP);
if (max <NP)
{
max = NP;
}
}
Console.Write("NAME\t GROSSPAY\t TOTALDEDUCTION\t NETPAY");
for(i=0; i < size; i++)
{
Console.WriteLine(name+ "\t" + gp + "\t" + td + "\t" + NP);
}
Console.ReadLine();


Console.write("do u want to continue yes/no ");
dec = Console.ReadLine();
Console.Clear();

ganito ba ?

562144
 
Comment

vespine

Honorary Poster
Paanu nyu po nakuha sir ung pinaka malaki at ung name ?

remember this
C#:
if (max <NP)
{
max = NP;
}
while true, ilagay mo sa variable ang index ng value ng NP .. (nilagyan ko ng since array siya.. and i ang ginamit mong variable sa loop)

tapos sa display naman..

ganito lang..

NetPay: NP[index];
Name: name[index];

gusto ko sana yung code nalang ibigay kaso mas maganda kase pag logic lang ang tinuturo :D
 
Comment

m0stwanted143

Honorary Poster
remember this
C#:
if (max <NP)
{
max = NP;
}
while true, ilagay mo sa variable ang index ng value ng NP .. (nilagyan ko ng since array siya.. and i ang ginamit mong variable sa loop)

tapos sa display naman..

ganito lang..

NetPay: NP[index];
Name: name[index];

gusto ko sana yung code nalang ibigay kaso mas maganda kase pag logic lang ang tinuturo :D
ang ginawa nyu po ba yung
C#:
Sa name at netpay sa dulo ito ba
Name[3]
Netpay[3]
Eh panu po un? Si User po ung mag iinput.
Paanu kung 10 ung nilagay nya tapos depende sa array index kung pang ilan un un dapat na ilalagay pero baka lang naman po kung ganyan ung ginawa mopo 😅😅
 
Comment

vespine

Honorary Poster
ang ginawa nyu po ba yung
C#:
Sa name at netpay sa dulo ito ba
Name[3]
Netpay[3]
Eh panu po un? Si User po ung mag iinput.
Paanu kung 10 ung nilagay nya tapos depende sa array index kung pang ilan un un dapat na ilalagay pero baka lang naman po kung ganyan ung ginawa mopo 😅😅

hindi.. dynamic na din yun..

mag instantiate ka lang ng isang variable for index..

like, int index = 0;
take this as reference

C#:
int[] arr = {1,2,7,4};
int index= 0 ;
int lowestVal = 0; //sabihin natin na bawal mag input ng below 1 ang user
for(int i =0; i < arr.Length; i++)
{
    if(arr[i] > lowestVal)
    {
        lowestVal = arr[i];
        index = i;
    }
}

//actually malapit nato sa sagot.. haha
 
Comment

vespine

Honorary Poster
C#:
static void Main(string[] args)
        {
            string dec = "YES";
            int size = 0;
            while (dec.ToUpper() == "YES")
            {
                Console.Write("NumberofCustomer: ");
                size = Convert.ToInt32(Console.ReadLine());
                string[] name = new string[size];
                double[] gp = new double[size];
                double[] td = new double[size];
                double[] NP = new double[size];
                double max = 0;
                int index = 0;

                for (int i = 0; i < size; i++)
                {
                    Console.Write("Input Name: ");
                    name[i] = Console.ReadLine();
                    Console.Write("GP: ");
                    gp[i] = double.Parse(Console.ReadLine());
                    Console.Write("Total Deduction: ");
                    td[i] = Convert.ToDouble(Console.ReadLine());
                    NP[i] = gp[i] - td[i];
                    Console.WriteLine("Netpay:" + NP[i]);
                    if (max < NP[i])
                    {
                        max = NP[i];
                        index = i;
                    }
                }
                Console.WriteLine();
                Console.WriteLine("NAME\t GROSSPAY\t TOTALDEDUCTION\t NETPAY");

                for (int i = 0; i < size; i++)
                {
                    Console.WriteLine(name[i] + "\t" + gp[i] + "\t" + td[i] + "\t" + NP[i]);
                }
                Console.ReadKey();


                Console.WriteLine("Employee with Highest Net Pay");
                Console.WriteLine("NET: {0}",NP[index]);
                Console.WriteLine("Name: {0}",name[index]);


                Console.Write("do u want to continue yes/no ");
                dec = Console.ReadLine();
                Console.Clear();
            }
        }

subukan mo nalang to..
may gagawin pa ako.. hahaha
 
Comment

m0stwanted143

Honorary Poster
C#:
static void Main(string[] args)
        {
            string dec = "YES";
            int size = 0;
            while (dec.ToUpper() == "YES")
            {
                Console.Write("NumberofCustomer: ");
                size = Convert.ToInt32(Console.ReadLine());
                string[] name = new string[size];
                double[] gp = new double[size];
                double[] td = new double[size];
                double[] NP = new double[size];
                double max = 0;
                int index = 0;

                for (int i = 0; i < size; i++)
                {
                    Console.Write("Input Name: ");
                    name[i] = Console.ReadLine();
                    Console.Write("GP: ");
                    gp[i] = double.Parse(Console.ReadLine());
                    Console.Write("Total Deduction: ");
                    td[i] = Convert.ToDouble(Console.ReadLine());
                    NP[i] = gp[i] - td[i];
                    Console.WriteLine("Netpay:" + NP[i]);
                    if (max < NP[i])
                    {
                        max = NP[i];
                        index = i;
                    }
                }
                Console.WriteLine();
                Console.WriteLine("NAME\t GROSSPAY\t TOTALDEDUCTION\t NETPAY");

                for (int i = 0; i < size; i++)
                {
                    Console.WriteLine(name[i] + "\t" + gp[i] + "\t" + td[i] + "\t" + NP[i]);
                }
                Console.ReadKey();


                Console.WriteLine("Employee with Highest Net Pay");
                Console.WriteLine("NET: {0}",NP[index]);
                Console.WriteLine("Name: {0}",name[index]);


                Console.Write("do u want to continue yes/no ");
                dec = Console.ReadLine();
                Console.Clear();
            }
        }

subukan mo nalang to..
may gagawin pa ako.. hahaha
Sir sumuko ka rin . Hahaha galing mo sir. The best idol. Sa uulitin sana 😂😂 Salamat idol
 
Comment

Like us on facebook

Online statistics

Members online
1,308
Guests online
1,142
Total visitors
2,450

Forum statistics

Threads
882,443
Messages
15,609,732
Members
1,410,092
Top