Monday, 5 January 2015

Contoh Script c# menghitung bangun datar persegi panjang dan lingkaran

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Auliya_rahmah
{
    class Program
    {
        static void Main(string[] args)
        {
            Menu:

            Console.WriteLine("Menu Hitung Bangun Datar: ");
            Console.WriteLine("1. Persegi Panjang");
            Console.WriteLine("2. Lingkakaran");
            Console.WriteLine("Masukkan Pilihan Anda [1,2]: ");
            int pil;
            string input;
            input = Console.ReadLine();
            int.TryParse(input, out pil);
            Console.Clear();
            switch (pil)
            {
                case 1: Console.WriteLine("1. Luas Persegi panjang");
                    int pjng, lbar, luas;
                    Console.Write("masukan panjang : ");
                    pjng = int.Parse(Console.ReadLine());
                    Console.Write("masukan lebar : ");
                    lbar = int.Parse(Console.ReadLine());
                    luas = pjng * lbar;
                    Console.WriteLine("luas = " + luas);
                    Console.ReadLine();
                    Console.Clear();
                    goto Menu;
                 

                case 2: Console.WriteLine("2. Luas Lingkaran");
                    double p,d,r, luas1;
                    Console.Write("masukan p : ");
                    p = int.Parse(Console.ReadLine());
                    Console.Write("masukan d : ");
                    d = int.Parse(Console.ReadLine());
                    Console.Write("masukan r : ");
                    r = int.Parse(Console.ReadLine());
                    luas1 = p*r*r;
                    Console.WriteLine("luas1 = " + luas1);
                    Console.ReadLine();
                    Console.Clear();
                    goto Menu;
                 
                
        }
    }
    }

}

Download script Link1 / Link2

No comments:

Post a Comment