selamat datang di dhodsoftware

kalkulator dengan c# console

selamat malam man teman..kalo ada yang mau buat aplikasi dari c# console,, kalkulator tepat nya..monggo di copy code nya :)

using System;

namespace latih_5
{
    class Program
    {
        static void Main()
        {
            string myText,keluar;
            int pilih, Nil1, Nil2, Hasil;

            /*PROSEDURE KOTAK(KOL1,BARIS1,KOL2,BAR2)*/
            Program.kotak(2, 1, 76, 5);  //kotak judul
            myText = "Contoh Tugas Akhir Pemrograman C sharp";
            Program.cetak(myText, (74 - myText.Length) / 2, 2);
            myText = "Wearnes Education Center Madiun";
            Program.cetak(myText, (74 - myText.Length) / 2, 3);


            Program.kotak(29, 6, 76, 23);  //kotak kanan


            Program.kotak(2, 6, 28, 23);   //kotak kiri
            keluar = "N";
            while (keluar == "N")
            {
                myText = "1. Penjumlahan";
                Program.cetak(myText, 5, 9);
                myText = "2. Pengurangan";
                Program.cetak(myText, 5, 10);
                myText = "3. Perkalian";
                Program.cetak(myText, 5, 11);
                myText = "4. Pembagian";
                Program.cetak(myText, 5, 12);
                myText = "5. keluar";
                Program.cetak(myText, 5, 13);
                myText = "Pilih No. Menu 1-5 :";
                Program.cetak(myText, 5, 15);
                pilih = int.Parse(Console.ReadLine());
                Program.bersih(30, 6, 76, 23);

                if (pilih == 1)
                {
                    myText = "Masukan Nilai 1   :";
                    Program.cetak(myText, 33, 10);
                    myText = "Masukan Nilai 2   :";
                    Program.cetak(myText, 33, 11);
                    Console.SetCursorPosition(55, 10);
                    Nil1 = int.Parse(Console.ReadLine());
                    Console.SetCursorPosition(55, 11);
                    Nil2 = int.Parse(Console.ReadLine());
                    Hasil = Nil1 + Nil2;
                    myText = "Hasil Penjumlahan   :";
                    Program.cetak(myText, 33, 13);
                    Console.SetCursorPosition(55, 13);
                    Console.Write(Hasil);

                }
                else if (pilih == 2)
                {
                    myText = "Masukan Nilai 1   :";
                    Program.cetak(myText, 33, 10);
                    myText = "Masukan Nilai 2   :";
                    Program.cetak(myText, 33, 11);
                    Console.SetCursorPosition(55, 10);
                    Nil1 = int.Parse(Console.ReadLine());
                    Console.SetCursorPosition(55, 11);
                    Nil2 = int.Parse(Console.ReadLine());
                    Hasil = Nil1 - Nil2;
                    myText = "Hasil Pengurangan   :";
                    Program.cetak(myText, 33, 13);
                    Console.SetCursorPosition(55, 13);
                    Console.Write(Hasil);
                }
                else if (pilih == 3)
                {
                    myText = "Masukan Nilai 1   :";
                    Program.cetak(myText, 33, 10);
                    myText = "Masukan Nilai 2   :";
                    Program.cetak(myText, 33, 11);
                    Console.SetCursorPosition(55, 10);
                    Nil1 = int.Parse(Console.ReadLine());
                    Console.SetCursorPosition(55, 11);
                    Nil2 = int.Parse(Console.ReadLine());
                    Hasil = Nil1 * Nil2;
                    myText = "Hasil Perkalian   :";
                    Program.cetak(myText, 33, 13);
                    Console.SetCursorPosition(55, 13);
                    Console.Write(Hasil);
                }

                else if (pilih == 4)
                {
                    myText = "Masukan Nilai 1   :";
                    Program.cetak(myText, 33, 10);
                    myText = "Masukan Nilai 2   :";
                    Program.cetak(myText, 33, 11);
                    Console.SetCursorPosition(55, 10);
                    Nil1 = int.Parse(Console.ReadLine());
                    Console.SetCursorPosition(55, 11);
                    Nil2 = int.Parse(Console.ReadLine());
                    Hasil = Nil1 / Nil2;
                    myText = "Hasil Pembagian:";
                    Program.cetak(myText, 33, 13);
                    Console.SetCursorPosition(55, 13);
                    Console.Write(Hasil);



                }
                else
                {
                    keluar = "Y";
                }
            }

        }
 
            static void bersih(int kl1, int br1, int kl2, int br2)
            {
                int x;
                for (x = br1 + 1; x < br2; x++)
                {
                    Console.SetCursorPosition(kl1, x);
                    Console.Write(new string(' ',kl2-kl1-1));
                }
            }
        static void cetak(string kata, int kl, int br)
        {
            Console.SetCursorPosition(kl,br);
                Console.Write(kata);
        }
        static void kotak(int kl1, int br1, int kl2, int br2)
        {
            //pojok
            Console.SetCursorPosition(kl1, br1);
            Console.WriteLine("┌");
            Console.SetCursorPosition(kl2, br1);
            Console.WriteLine("┐");
            Console.SetCursorPosition(kl1, br2);
            Console.WriteLine("└");
            Console.SetCursorPosition(kl2, br2);
            Console.WriteLine("┘");
            //hor
            Console.SetCursorPosition(kl1 +1, br1);
            Console.Write(new string('▬' ,kl2-kl1-1));
            Console.SetCursorPosition(kl1 +1, br2);
            Console.Write(new string('▬' ,kl2-kl1-1));
            //ver
            int x;
            for (x = br1 + 1; x < br2; x++)
            {
                Console.SetCursorPosition(kl1, x);
                Console.WriteLine("│");
                Console.SetCursorPosition(kl2, x);
                Console.WriteLine("│");
            }            //Console.ReadKey();
        }
    }

}



Previous
Next Post »