http://2.bp.blogspot.com/-oIHX-_ztj-0/UlakOB5viCI/AAAAAAAABTo/OPsZQehrC9Y/s1600/burung.png ™Welcome To My Blog...!!!: Maret 2016

Kamis, 17 Maret 2016

C# Menggunakan fungsi IF dalam pemilihan Buku

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

namespace Buku
{
    class Program
    {
        struct book
        {
            private string title;
            private string authors;
            private string subject;
            private int book_id;

            public void getValues(string t, string a, string s, int id)
            {
                title = t;
                authors = a;
                subject = s;
                book_id = id;
            }

            public void display()
            {
                Console.WriteLine("Buku yang dimaksud memiliki spesifikasi seperti berikut : ");
                Console.WriteLine("Title = {0}", title);
                Console.WriteLine("Authors = {0}", authors);
                Console.WriteLine("Subject = {0}", subject);
                Console.WriteLine("Book ID = {0}", book_id);
            }
        };

        public class testStructure
        {
            static void Main(string[] args)
            {
                book Book1 = new book();
                book Book2 = new book();

                Book1.getValues("C Programming", "Nuha Ali", "C Programming Tutorial", 6495407);
                Book2.getValues("Telecom Billing", "Zahra Ali", "Telecom Billing Tutorial", 6495700);

               
                Console.WriteLine("Buku 1 ID = 6495407");
                Console.WriteLine("Buku 2 ID = 6495700 \n");

                Console.WriteLine("Masukkan ID : ");
                int a = int.Parse(Console.ReadLine());

                if (a == 6495407)
                {
                    Book1.display();
                }
                if (a == 6495700)
                {
                    Book2.display();
                }

                Console.ReadKey();
            }
        }
    }
}

C# BUBBLE SORT

namespace Praktikum_5_1_13050974024
{
    class Program
    {
        static void Main(string[] args)
        {
            int angka, x;
            Console.WriteLine();
            Console.WriteLine(" ==========Metode Bubble Sort==============");
            Console.WriteLine();
            Console.Write(" Masukkan Banyak Angka : ");
            angka = int.Parse(Console.ReadLine());
            int[] array = new int[angka];
            Console.WriteLine();

            for (x = 0; x < angka; x++)
            {
                Console.Write(" Angka Ke-" + (x + 1) + " : ");
                array[x] = int.Parse(Console.ReadLine());
            }
            Console.WriteLine();
            Console.WriteLine(" Sebelum Diurutkan");
            for (x = 0; x < angka; x++)
            {
                Console.Write(" " + array[x]);
            }
            Console.WriteLine();
            for (int y = 0; y <= angka - 1; y++)
            {
                for (int z = 0; z <= angka - 2; z++)
                {
                    if (array[z] > array[z + 1])
                    {
                        int temp = array[z + 1];
                        array[z + 1] = array[z];
                        array[z] = temp;
                    }
                }
            }

            Console.WriteLine();
            Console.WriteLine(" Ascending Sort");
            for (x = 0; x < angka; x++)
            {
                Console.Write(" " + array[x]);
            }
            Console.WriteLine();
            for (int y = 0; y <= angka - 1; y++)
            {
                for (int z = 0; z <= angka - 2; z++)
                {
                    if (array[z] < array[z + 1])
                    {
                        int temp = array[z];
                        array[z] = array[z + 1];
                        array[z + 1] = temp;
                    }
                }
            }

            Console.WriteLine();
            Console.WriteLine(" Descending Sort");
            for (int i = 0; i < angka; i++)
            {
                Console.Write(" " + array[i]);
            }

            Console.ReadLine();
        }
    }
}