Contoh Progam C# Toko Buku dengan Visual Studio 2015

Berikut contoh program C# yang saya buat sebagai tugas Mata Kuliah Algoritma & Pemrograman  menggunakan Visual Studio 2015 yang mana saya dibantu oleh teman saya Risqi Nugraha :


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

namespace firman
{
    class Program
    {
        static void Main(string[] args)
        {
            string a, b, b1, b11, b12, b13, b2, b21, b22, b23, b3, c, jenisCustomer, judulBuku;
            double harga, diskonMember, total;

            awal:
            Console.WriteLine(" SELAMAT DATANG DI TOKO BUKU");
            Console.WriteLine();
            Console.WriteLine();

            a:
            Console.WriteLine(" Jenis Customer");
            Console.WriteLine();
            Console.WriteLine(" 1. Member        20%");
            Console.WriteLine(" 2. Non Member    10%");
            Console.WriteLine();
            Console.Write(" Pilih Jenis Customer = ");
            a = Console.ReadLine();
            Console.WriteLine();
            switch (a)
            {
                case "1":
                    jenisCustomer = "Member";
                    diskonMember = 0.2;
                    break;
                case "2":
                    jenisCustomer = "Non Member";
                    diskonMember = 0.1;
                    break;
                default:
                    Console.WriteLine(" Maaf Pilihan Tidak Tersedia");
                    Console.WriteLine(" Silahkan Ulangi Lagi");
                    Console.WriteLine();
                    goto a;
            }

            b:
            Console.WriteLine(" Jenis Buku");
            Console.WriteLine();
            Console.WriteLine(" 1. Komik");
            Console.WriteLine(" 2. Novel");
            Console.WriteLine(" 3. Ensiklopedi");
            Console.WriteLine();
            Console.Write(" Pilih Genre Buku = ");
            b = Console.ReadLine();
            Console.WriteLine();
            switch (b)
            {
                case "1":
                    b1:
                    Console.WriteLine(" 1. Komik Tahunan");
                    Console.WriteLine(" 2. Komik Wayang");
                    Console.WriteLine(" 3. Komik Majalah");
                    Console.WriteLine();
                    Console.Write(" Pilih Judul Buku = ");
                    b1 = Console.ReadLine();
                    Console.WriteLine();
                    switch (b1)
                    {
                        case "1":
                            Console.WriteLine(" 1. BATMAN ANNUAL #1: NIGHT OF OWLS");
                            Console.WriteLine(" 2. FANTASTIC FOUR ANNUAL #3");
                            Console.WriteLine(" 3. AMAZING FANTASY #15");
                            Console.WriteLine();
                            Console.Write(" Pilih Judul Buku = ");
                            b11 = Console.ReadLine();
                            switch (b11)
                            {
                                case "1":
                                    judulBuku = "BATMAN ANNUAL #1: NIGHT OF OWLS";
                                    harga = 50000;
                                    break;
                                case "2":
                                    judulBuku = "FANTASTIC FOUR ANNUAL #3";
                                    harga = 50000;
                                    break;
                                case "3":
                                    judulBuku = "AMAZING FANTASY #15";
                                    harga = 50000;
                                    break;
                                default:
                                    judulBuku = "Maaf Tidak Tersedia";
                                    harga = 0;
                                    break;
                            }
                            break;

                        case "2":
                            Console.WriteLine(" 1. LAHIRNYA GATOTKATJA");
                            Console.WriteLine(" 2. RADEN PALASARA");
                            Console.WriteLine(" 3. MAHABHARATA");
                            Console.WriteLine();
                            Console.Write(" Pilih Judul Buku = ");
                            b12 = Console.ReadLine();
                            switch (b12)
                            {
                                case "1":
                                    judulBuku = "LAHIRNYA GATOTKATJA";
                                    harga = 35000;
                                    break;
                                case "2":
                                    judulBuku = "RADEN PALASARA";
                                    harga = 25000;
                                    break;
                                case "3":
                                    judulBuku = "MAHABHARATA";
                                    harga = 49000;
                                    break;
                                default:
                                    judulBuku = "Maaf Tidak Tersedia";
                                    harga = 0;
                                    break;
                            }
                            break;

                        case "3":
                            Console.WriteLine(" 1. RE:ON");
                            Console.WriteLine(" 2. SHONEN FIGHT");
                            Console.WriteLine(" 3. KOSMIK");
                            Console.WriteLine();
                            Console.Write(" Pilih Judul Buku = ");
                            b13 = Console.ReadLine();
                            switch (b13)
                            {
                                case "1":
                                    judulBuku = "RE:ON";
                                    harga = 35500;
                                    break;
                                case "2":
                                    judulBuku = "SHONEN FIGHT";
                                    harga = 32000;
                                    break;
                                case "3":
                                    judulBuku = "KOSMIK";
                                    harga = 24000;
                                    break;
                                default:
                                    judulBuku = "Maaf Tidak Tersedia";
                                    harga = 0;
                                    break;
                            }
                            break;

                        default:
                            Console.WriteLine();
                            Console.WriteLine("Maaf Pilihan Tidak Tersedia");
                            Console.WriteLine("Silahkan Ulangi Lagi");
                            Console.WriteLine();
                            goto b1;
                    }
                    break;

                case "2":
                    Console.WriteLine(" 1. Novel Fiksi");
                    Console.WriteLine(" 2. Novel Non Fiksi");
                    Console.WriteLine(" 3. Novel Thriller");
                    Console.WriteLine();
                    Console.Write(" Pilih Genre Buku = ");
                    b2 = Console.ReadLine();
                    Console.WriteLine();
                    switch (b2)
                    {
                        case "1":
                            Console.WriteLine(" 1. DEAR NATHAN");
                            Console.WriteLine(" 2. LASKAR PELANGI");
                            Console.WriteLine(" 3. SANG PEMIMPI");
                            Console.WriteLine();
                            Console.Write(" Pilih Judul Buku = ");
                            b21 = Console.ReadLine();
                            switch (b21)
                            {
                                case "1":
                                    judulBuku = "DEAR NATHAN";
                                    harga = 99000;
                                    break;
                                case "2":
                                    judulBuku = "LASKAR PELANGI";
                                    harga = 70000;
                                    break;
                                case "3":
                                    judulBuku = "SANG PEMIMPI";
                                    harga = 86000;
                                    break;
                                default:
                                    judulBuku = "Maaf Tidak Tersedia";
                                    harga = 0;
                                    break;
                            }
                            break;

                        case "2":
                            Console.WriteLine(" 1. KAMUS BESAR BAHASA INDONESIA");
                            Console.WriteLine(" 2. SELASA BERSAMA MORRIE");
                            Console.WriteLine(" 3. OPERACION MASACRE");
                            Console.WriteLine();
                            Console.Write(" Pilih Judul Buku = ");
                            b22 = Console.ReadLine();
                            switch (b22)
                            {
                                case "1":
                                    judulBuku = "KAMUS BESAR BAHASA INDONESIA";
                                    harga = 510000;
                                    break;
                                case "2":
                                    judulBuku = "SELASA BERSAMA MORRIE";
                                    harga = 68000;
                                    break;
                                case "3":
                                    judulBuku = "OPERACION MASACRE";
                                    harga = 95500;
                                    break;
                                default:
                                    judulBuku = "Maaf Tidak Tersedia";
                                    harga = 0;
                                    break;
                            }
                            break;

                        case "3":
                            Console.WriteLine(" 1. PEMBUNUHAN DI ATAS ORIENT EXPRESS");
                            Console.WriteLine(" 2. INFERNO");
                            Console.WriteLine(" 3. TIGA SANDERA TERAKHIR");
                            Console.WriteLine();
                            Console.Write(" Pilih Judul Buku = ");
                            b23 = Console.ReadLine();
                            switch (b23)
                            {
                                case "1":
                                    judulBuku = "PEMBUNUHAN DI ATAS ORIENT EXPRESS";
                                    harga = 135000;
                                    break;
                                case "2":
                                    judulBuku = "INFERNO";
                                    harga = 105000;
                                    break;
                                case "3":
                                    judulBuku = "TIGA SANDERA TERAKHIR";
                                    harga = 125000;
                                    break;
                                default:
                                    judulBuku = "Maaf Tidak Tersedia";
                                    harga = 0;
                                    break;
                            }
                            break;

                        default:
                            Console.WriteLine();
                            Console.WriteLine(" Maaf Pilihan Tidak Tersedia");
                            Console.WriteLine(" Silahkan Ulangi Lagi");
                            Console.WriteLine();
                            goto b1;
                    }
                    break;
                case "3":
                    Console.WriteLine(" 1. Ensiklopedi Umum/Nasional");
                    Console.WriteLine(" 2. Ensiklopedi Khusus/Subyek");
                    Console.WriteLine(" 3. Ensiklopedi Internasional");
                    Console.Write(" Pilih Judul Buku = ");
                    b3 = Console.ReadLine();
                    switch (b3)
                    {
                        case "1":
                            judulBuku = "Ensiklopedi Umum/Nasional";
                            harga = 100000;
                            break;
                        case "2":
                            judulBuku = "Ensiklopedi Khusus/Subyek";
                            harga = 96000;
                            break;
                        case "3":
                            judulBuku = "Ensiklopedi Internasional";
                            harga = 150000;
                            break;
                        default:
                            judulBuku = "Maaf Tidak Tersedia";
                            harga = 0;
                            break;
                    }
                    break;
                default:
                    Console.WriteLine(" Maaf Pilihan Tidak Tersedia");
                    Console.WriteLine(" Silahkan Ulangi Lagi");
                    Console.WriteLine();
                    goto b;
            }
            total = harga - (diskonMember * harga);
            Console.WriteLine();
            Console.WriteLine(" STRUK PEMBELIAN BUKU");
            Console.WriteLine();
            Console.WriteLine(" Jenis Customer   = " + jenisCustomer);
            Console.WriteLine(" Judul Buku       = " + judulBuku);
            Console.WriteLine(" Harga Buku       = " + harga);
            Console.WriteLine();
            Console.WriteLine(" Total Harga      = " + total);
            Console.WriteLine();
            Console.Write(" Apakah Anda Ingin Beli Ulang [Y/T] = ");
            c = Console.ReadLine();
            if (c == "Y" || c== "y")
            {
                Console.Clear();
                goto awal;
            }
            else
            {
                Console.WriteLine("Terimakasih");
            }
            Console.ReadKey();

        }
    }
}

Output :


Komentar

Postingan Populer