IJUL'S BLOG

Menghitung Data Pekerja di C#

ni contoh source code menngunakan console application:



namespace ConsoleAplication1
{
    class program
    {
        static void Main(string[] args)
        {
            Console.Write("Jumlah Pekerja= ");
            int n = int.Parse(Console.In.ReadLine());
            data2 p1 = new data2(n);
            p1.data1(n);
            Console.Clear();
            p1.cetak(n);
            Console.ReadLine();
        }
    }
    class data2
    {
        public int n;
        string[] nama = new string[10];
        int[] usia = new int[50];
        string[] kelamin = new string[10];
        int[] gaji = new int[50];
        double[] upah = new double[50];

        public data2(int n)
        {
            this.n = n;
        }
        public void data1(int n)
        {
         
         
            for (int i=1;i<=n;i++)
            {
                Console.Write("Inputkan Nama= ");
                nama[i] = Console.In.ReadLine();
                Console.Write("Inputkan Usia= ");
                usia[i] = int.Parse(Console.In.ReadLine());
                Console.Write("Inputkan Jenis kelamin= ");
                kelamin[i] = Console.In.ReadLine();
                Console.Write("Inputkan Gaji= ");
                gaji[i] = int.Parse(Console.In.ReadLine());
                Console.Write("Inputkan Jam Lembur= ");
                upah[i] = double.Parse(Console.ReadLine());
             
                Console.WriteLine();
            }
         
        }
          public void cetak(int n)
            {
            Console.WriteLine();
            Console.WriteLine("NAMA\t|USIA\t|KELAMIN\t|GAJI\t|\tUPAH LEMBUR\t|GAJI TOTAL|");
            Console.Write("___________________________________________________________"+"\n");
              for (int j = 1; j <= n; j++)
            {
                Console.Write(nama[j]+"\t");
                Console.Write(usia[j]+"\t");
                Console.Write(kelamin[j]+"\t");
                Console.Write("Rp."+gaji[j]+"\t");
                Console.Write("Rp."+(upah[j]*50000)+"\t");
                Console.Write("Rp." + (gaji[j]+(upah[j] * 50000)));
                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}

0 komentar:

Posting Komentar

Powered By Blogger
Diberdayakan oleh Blogger.

Entri Populer

PENGUNJUNG

Buku Tamu

About Me

Foto Saya
Ijal Ferdi
there is no something special about me,,, but this blog is so special for me......
View my complete profile

Total Tayangan Halaman

Followers