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

Addict
Established
Joined
Feb 8, 2016
Messages
348
Reaction score
60
 

vespine

Honorary Poster
if galing database yan, I usually use entity framework.. tapos iso-sort sa highest ang netpay.. tapos display nalang.. :D
 
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 .
 

vespine

Honorary Poster
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 .
show mo daw code.
 
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();
 

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
 

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
 
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 😅😅
 

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
 

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
 
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
 

aa1012

Enthusiast
kung galing yan sa database, query mo lang yung table mo tapos gamit ka ng MAX sql function.
 

Trending Topics

Trending On This Forum

New Topics On This Forum

Top