예제 #1
0
파일: Class1.cs 프로젝트: yohanaayose/OOP
        static void Main(string[] args)
        {
            Console.WriteLine(" ===================================");
            Console.WriteLine(" ===   PERHITUNGAN KELILING     ====");
            Console.WriteLine(" ===================================");
            Console.WriteLine(" ======     1. Segitiga      =======");
            Console.WriteLine(" ======     2. Lingkaran     =======");
            Console.WriteLine(" ======  3. Persegi Panjang  =======");
            Console.WriteLine(" =========  4. Trapesium     =======");
            Console.WriteLine(" ===================================");
            Console.WriteLine(" ===   PILIHAN MENU : ....     ====");
            Console.WriteLine(" ===================================");
            double nomor = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("====================================");

            if (nomor == 1)
            {
                Console.WriteLine();
                Console.Write("Masukkan sisi  : ");
                double  side = Convert.ToDouble(Console.ReadLine());
                process p    = new triangle(side);
                double  l    = p.processing();
                Console.WriteLine("Keliling Segitiga : " + l);
            }
            else if (nomor == 2)

            {
                Console.Write("Masukkan jari-jari : ");
                double  radius = Convert.ToDouble(Console.ReadLine());
                process a      = new circle(radius);
                double  b      = a.processing();
                Console.WriteLine("Keliling Lingkaran : " + b);
            }
            else if (nomor == 3)
            {
                Console.Write("Masukkan panjang: ");
                double panjang = Convert.ToDouble(Console.ReadLine());
                Console.Write("Masukkan lebar : ");
                double  lebar = Convert.ToDouble(Console.ReadLine());
                process x     = new rectangle(panjang, lebar);
                double  y     = x.processing();
                Console.WriteLine("Keliling Persegi Panjang : " + y);
            }
            else
            {
                Console.Write("Masukkan side : ");
                double  side = Convert.ToDouble(Console.ReadLine());
                process m    = new trapezoid(side);
                double  n    = m.processing();
                Console.WriteLine("Keliling Trapesium : " + n);
            }
            Console.Read();
        }
예제 #2
0
        static void Main(string[] args)
        {
            rectangle four_ygl = new rectangle(5, 7);

            four_ygl.print_S();
            square kvadr = new square(10);

            kvadr.print_S();
            circle circ = new circle(33);

            circ.print_S();

            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            Shapes s = new Shapes(new Point2D());
            s.centroid.x = 2;
            s.centroid.y = 3;

            circle c = new circle(new Point2D());
            c.centroid.x = 1;
            c.centroid.y = -3;
            c.area = 5;

            rectangle r = new rectangle(new Point2D());
            r.centroid.x = 0;

            Console.ReadLine();
        }
예제 #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("=================================== :");
            Console.WriteLine("PERHITUNGAN KELILING :");
            Console.WriteLine("=================================== :");
            Console.WriteLine("1. Segitiga :");
            Console.WriteLine("2. Lingkaran :");
            Console.WriteLine("3. Persegi Panjang :");
            Console.WriteLine("4. Trapesium :");
            Console.WriteLine("====================================");
            Console.Write("Pilihan Menu :");
            double nomor = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("====================================");

            if (nomor == 1)
            {
                Console.WriteLine();
                Console.Write("Masukkan sisi pertama : ");
                double side1 = Convert.ToDouble(Console.ReadLine());
                Console.Write("Masukkan sisi kedua : ");
                double side2 = Convert.ToDouble(Console.ReadLine());
                Console.Write("Masukkan sisi ketiga : ");
                double  side3 = Convert.ToDouble(Console.ReadLine());
                process p     = new triangle(side1, side2, side3);
                double  l     = p.processing();
                Console.WriteLine("Keliling Segitiga : " + l);
            }
            else if (nomor == 2)

            {
                Console.Write("Masukkan jari : ");
                double  jari = Convert.ToDouble(Console.ReadLine());
                process a    = new circle(jari);
                double  b    = a.processing();
                Console.WriteLine("Keliling Lingkaran : " + b);
            }
            else if (nomor == 3)
            {
                Console.Write("Masukkan panjang: ");
                double panjang = Convert.ToDouble(Console.ReadLine());
                Console.Write("Masukkan lebar : ");
                double  lebar = Convert.ToDouble(Console.ReadLine());
                process x     = new rectangle(panjang, lebar);
                double  y     = x.processing();
                Console.WriteLine("Keliling Persegi Panjang : " + y);
            }
            else
            {
                Console.Write("Masukkan side pertama: ");
                double sideA = Convert.ToDouble(Console.ReadLine());
                Console.Write("Masukkan side kedua : ");
                double sideB = Convert.ToDouble(Console.ReadLine());
                Console.Write("Masukkan side ketiga : ");
                double sideC = Convert.ToDouble(Console.ReadLine());
                Console.Write("Masukkan side keempat : ");
                double  sideD = Convert.ToDouble(Console.ReadLine());
                process m     = new trapezoid(sideA, sideB, sideC, sideD);
                double  n     = m.processing();
                Console.WriteLine("Keliling Trapesium : " + n);
            }
            Console.Read();
        }
예제 #5
0
        static void Main(string[] args)
        {
            square sq1 = new square(2, 3);

            circle cr = new circle(2, 3, 4);

            cr.show();
            sq1.show();

            //Task_01
            Console.Write("***********\nTASK_01\n***********\n");
            square sq = new square(2, 3);

            Console.WriteLine(sq.ToString());

            Console.Write("\n\n***********\nTASK_02\n***********\n");
            Console.Write("\nEnter value 1: ");
            double a = double.Parse(Console.ReadLine());

            Console.Write("\nEnter value 2: ");
            double b = double.Parse(Console.ReadLine());

            //circle c=new circle(2,3,4);

            calculator cal = new calculator(a, b);

            int i = 1;

            while (i == 1)
            {
                Console.WriteLine("\nChoose any one operation:\n");
                Console.WriteLine("1: ADD\n");
                Console.WriteLine("2: SUBSTRACT\n");
                Console.WriteLine("3: MULTIPLY\n");
                Console.WriteLine("4: DIVIDE\n");
                Console.WriteLine("0: EXIT\n");

                int opt = int.Parse(Console.ReadLine());
                if (opt == 1)
                {
                    Console.WriteLine("\n" + a + "+" + b + "= " + cal.add());
                }
                else if (opt == 2)
                {
                    Console.WriteLine("\n" + a + "-" + b + "= " + cal.sub());
                }
                else if (opt == 3)
                {
                    Console.WriteLine("\n" + a + "*" + b + "= " + cal.mul());
                }
                else if (opt == 4)
                {
                    Console.WriteLine("\n" + a + "/" + b + "= " + cal.div());
                }
                else if (opt == 0)
                {
                    i = 0;
                }
            }

            //Console.WriteLine(c.ToString());

            Console.ReadKey();
        }