Monday 5 January 2015

Contoh script nested case pada c#

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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
           
            Console.WriteLine("MENU PAKET HEMAT");
            Console.WriteLine("CAFE...MMMYUMMY");
            Console.WriteLine("1. PaMat 1");
            Console.WriteLine("2. PaMat 2");
            Console.WriteLine("3. Selesai");
            Console.Write("Masukan pilihan anda : ");
            string pilih = Console.ReadLine();

            switch (pilih)
            {
                case "1":
                    {
                        int harga = 20000;
                        Console.WriteLine("Menu PaMat 1 Rp" + harga);
                        Console.WriteLine("Nasi+Ayam Kremes+Soup+Soft Drink");
                        Console.Write("Masukan Jumlah Pesanan Anda ? ");
                        int jumlah = Convert.ToInt32( Console.ReadLine());
                        int total;
                        total = harga * jumlah;
                        Console.WriteLine("Total Pembayaran Anda : " + total);
                    }
                    break;

                case "2":
                    {
                        int harga1 = 15000;
                        Console.WriteLine("Menu PaMat 1 Rp" + harga1);
                        Console.WriteLine("Nasi+Ayam Kremes+Soft Drink");
                        Console.Write("Masukan Jumlah Pesanan Anda ? ");
                        int jumlah1 = Convert.ToInt32(Console.ReadLine());
                        int total1;
                        total1 = harga1 * jumlah1;
                        Console.WriteLine("Total Pembayaran Anda : " + total1);
                    }
                    break;

                case "3":
                    {
                        Console.WriteLine("Program selesai");
                    }
                    break;

               
            }
           
        }
    }
}


Download script Link1 / Link2



No comments:

Post a Comment