Friday, March 4, 2011

SELISIH WAKTU


using System;
namespace Selisih_Waktu_0320100003
{
            class Class1
            {
                        public struct jam
                        {
                                    public int hh;
                                    public int mm;
                                    public int ss;
                        }
                        static void Main(string[] args)
                        {
                                    jam w1;
                                    jam w2;
                                    jam w3;
                                    Console.Write("Masukkan jam mulai :");
                                    w1.hh=Convert.ToInt32(Console.ReadLine());
                                    Console.Write("Masukkan menit mulai :");
                                    w1.mm=Convert.ToInt32(Console.ReadLine());
                                    Console.Write("Masukkan Detik Mulai :");
                                    w1.ss=Convert.ToInt32(Console.ReadLine());
                                    Console.Write("Masukkan jam selesai :");
                                    w2.hh=Convert.ToInt32(Console.ReadLine());
                                    Console.Write("Masukkan menit Selesai :");
                                    w2.mm=Convert.ToInt32(Console.ReadLine());
                                    Console.Write("Masukkan detik selesai :");
                                    w2.ss=Convert.ToInt32(Console.ReadLine());
                                    if(w2.ss>=w1.ss)
                                    {
                                                w3.ss=w2.ss-w1.ss;
                                                if(w2.mm>=w1.mm)
                                                {
                                                            w3.mm=w2.mm-w1.mm;
                                                            w3.hh=w2.hh-w1.hh;
                                                            Console.WriteLine("{0},{1},{2}",w3.hh,w3.mm,w3.ss);
                                                }
                                                if(w2.mm<w1.mm)
                                                {
                                                            w3.mm=(w2.mm+60)-w1.mm;
                                                            w2.hh=w2.hh-1;
                                                            w3.hh=w2.hh-w1.hh;
                                                            Console.WriteLine("{0},{1},{2}",w3.hh,w3.mm,w3.ss);
                                                }
                                               
                                    }
                                    if(w2.ss<w1.ss)
                                    {
                                                w3.ss=(w2.ss+60)-w1.ss;
                                                w2.mm=w2.mm-1;
                                                if(w2.mm>=w1.mm)
                                                {
                                                            w3.mm=w2.mm-w1.mm;
                                                            w3.hh=w2.hh-w1.hh;
                                                            Console.WriteLine("{0},{1},{2}",w3.hh,w3.mm,w3.ss);
                                                }
                                                if(w2.mm<w1.mm)
                                                {
                                                            w3.mm=(w2.mm+60)-w1.mm;
                                                            w2.hh=w2.hh-1;
                                                            w3.hh=w2.hh-w1.hh;
                                                            Console.WriteLine("{0},{1},{2}",w3.hh,w3.mm,w3.ss);
                                                }
                                    }
                                    Console.ReadLine();
                                   
                        }
            }
}

FAKTORIAL


using System;

namespace Faktorial_0320100003
{
                class Class1
                {
                                static void Main(string[] args)
                                {
                                                int x,i,l,fak;
                                                Console.Write("Masukkan Bilangan : ");
                                                x=Convert.ToInt32(Console.ReadLine());

                                                if(x==0)
                                                {
                                                                Console.WriteLine("Faktorial : 1");
                                                }
                                                else
                                                {
                                                                fak=1;
                                                                for(i=x;i>=1;i--)
                                                                {
                                                                                l=fak*i;
                                                                                fak=l;
                                                                }
                                                                Console.WriteLine("Faktorial : {0}", fak);
                                                }
                                                Console.ReadLine();
                                }
                }
}

KALKULATOR


using System;

namespace Kalkulator_0320100003
{
                class Class1
                {             
                                static void Main(string[] args)
                                {
                                                double x,y,z;
                                                string e;
                                               
                                                Console.Write("Angka 1 : ");
                                                x=Convert.ToInt32(Console.ReadLine());
                                                Console.Write("Operator ( +, -, *, / ) : ");
                                                e=Convert.ToString(Console.ReadLine());

                                                if(e=="+")
                                                {
                                                                Console.Write("Angka 2 : ");
                                                                y=Convert.ToInt32(Console.ReadLine());
                                                                z=x+y;
                                                                Console.WriteLine("Jumlah adalah {0} ", z);
                                                }
                                                else
                                                                if(e=="-")
                                                {
                                                                Console.Write("Angka 2 : ");
                                                                y=Convert.ToInt32(Console.ReadLine());
                                                                z=x-y;
                                                                Console.WriteLine("Jumlah adalah {0} ", z);
                                                }
                                                else
                                                                if(e=="*")
                                                                {
                                                                                Console.Write("Angka 2 : ");
                                                                                y=Convert.ToInt32(Console.ReadLine());
                                                                                z=x*y;
                                                                                Console.WriteLine("Jumlah adalah {0} ", z);
                                                }
                                                else
                                                {
                                                                Console.Write("Angka 2 : ");
                                                                y=Convert.ToInt32(Console.ReadLine());
                                                                z=x/y;
                                                                Console.WriteLine("Jumlah adalah {0} ", z);
                                                }
                                                Console.ReadLine();

                                }
                }
}

PERBANDINGAN ANGKA


using System;

namespace Perbandingan_angka_0320100003
{
                class Class1
                {
                                static void Main(string[] args)
                                {
                                                int x,y,z;
                                                Console.Write("A=? ");
                                                x=Convert.ToInt32(Console.ReadLine());
                                                Console.Write("B=? ");
                                                y=Convert.ToInt32(Console.ReadLine());
                                                Console.Write("C=? ");
                                                z=Convert.ToInt32(Console.ReadLine());

                                                if(x>=y )
                                                {
                                                                if(x>=z)
                                                                {
                                                                                Console.WriteLine("Bilangan Terbesar adalah {0}", x);
                                                                }
                                                                else
                                                                {
                                                                                Console.WriteLine("Bilangan Terbesar adalah {0}", z);
                                                                }
                                                }
                                                else
                                                                if (y>=z)
                                                {
                                                                Console.WriteLine("Bilangan Terbesar adalah {0}", y);
                                                }
                                                else
                                                {
                                                                Console.WriteLine("Bilangan Terbesar adalah {0}", z);
                                                }
                                               
                                                Console.ReadLine();

                                }
                }
}

HELLO WORLD


using System;

namespace HelloWorld_0320100003
{
            class Class1
            {
                        static void Main(string[] args)
                        {
                                    Console.WriteLine("Hello World");
                                    Console.ReadLine();
                        }
            }
}

VARIABEL, KONSTANTA, TIPE DATA



using System;

namespace variabel_0320100003
{
            class Class1
            {
                        static void Main(string[] args)
                        {
                                    int no;
float luas=3.54f;
                                    string text;
                                    text="Hello Intan";
no=1;
                                    Console.WriteLine("{0}",text);
                                    Console.WriteLine("{0}",no);
                                    Console.WriteLine("{0}",luas);
                                    Console.ReadLine();
                        }
            }
}