Pemrograman 2: C# (C-Sharp)
Tanggal 28 Februari 2011
1) Hello World !
================
using System;
namespace HelloWorld
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
Console.WriteLine("Hello, World !");
Console.ReadLine();
}
}
}
2) Variabel, Konstanta, Tipe Data
=================================
using System;
namespace VariabelKonstantaTipedata
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
int a=5,b;
b=a+1;
Console.WriteLine("{0}",b);
Console.ReadLine();
}
}
}
3) Operator
===========
using System;
namespace Operator
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
int pilihan,a,b,c;
string jawab;
START:
Console.Write("1. Penambahan\n2. Pengurangan\n3. Pembagian\n4. Perkalian\nPilih nomor: ");
pilihan = Convert.ToInt32(Console.ReadLine());
if (pilihan == 1)
{
Console.Write("Masukkan bilangan pertama: ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Masukkan bilangan kedua: ");
b = Convert.ToInt32(Console.ReadLine());
c = a + b;
Console.WriteLine("Penambahan dari {0} dan {1} adalah {2}",a,b,c);
}
if (pilihan == 2)
{
Console.Write("Masukkan bilangan pertama: ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Masukkan bilangan kedua: ");
b = Convert.ToInt32(Console.ReadLine());
c = a - b;
Console.WriteLine("Pengurangan dari {0} dan {1} adalah {2}",a,b,c);
}
if (pilihan == 3)
{
Console.Write("Masukkan bilangan pertama: ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Masukkan bilangan kedua: ");
b = Convert.ToInt32(Console.ReadLine());
c = a / b;
Console.WriteLine("Pembagian dari {0} dan {1} adalah {2}",a,b,c);
}
if (pilihan == 4)
{
Console.Write("Masukkan bilangan pertama: ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Masukkan bilangan kedua: ");
b = Convert.ToInt32(Console.ReadLine());
c = a * b;
Console.WriteLine("Perkalian dari {0} dan {1} adalah {2}",a,b,c);
}
if (pilihan>4)
{
Console.WriteLine("Anda salah memasukkan kode");
}
Console.Write("Ingin mengulang lagi? [y/t]");
jawab = Console.ReadLine();
if (jawab == "y")
{
goto START;
}
}
}
}
4) If
======
using System;
namespace If
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
string jawaban;
Console.Write("Apa gender anda[p/l]? ");
jawaban = Console.ReadLine();
if(jawaban=="l")
{
Console.Write("Selamat Pagi, Mas");
}
if(jawaban=="p")
{
Console.Write("Selamat Pagi, Mbak");
}
if(jawaban != "p" && jawaban != "l")
{
Console.Write("Selamat Pagi ... Ah ,gender apaan nih?");
}
Console.ReadLine();
}
}
}
5) Array
========
using System;
namespace Array
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
int a,b;
int[,] angka = new int[4,4];
for(a=0;a<4;a++)
{
for(b=0;b<=a;b++)
{
angka[a,b]=0;
}
}
b=0;
for(a=0;a<4;a++)
{
angka[a,b]=1;
b=b+1;
}
for(a=0;a<4;a++)
{
for(b=0;b<4;b++)
{
Console.Write("{0}",angka[a,b]);
}
Console.Write("\n");
}
Console.ReadLine();
}
}
}
6) Loop
=======
using System;
namespace Loop
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
int a,b;
for(a=0;a<5;a++)
{
for(b=0;b<=a;b++)
{
Console.Write("* ** *");
}
Console.Write("\n");
}
Console.ReadLine();
}
}
}
7) Input & Output
=================
using System;
namespace InputOutput
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
string username,password,nama,NIM,jawab;
do
{
Console.WriteLine("Daftarkan keanggotaan perpustakaan");
Console.Write("Username: ");
username=Console.ReadLine();
Console.Write("Password: ");
password=Console.ReadLine();
Console.Write("Nama : ");
nama=Console.ReadLine();
Console.Write("NIM : ");
NIM=Console.ReadLine();
Console.WriteLine("Username: {0}",username);
Console.WriteLine("Password: {0}",password);
Console.WriteLine("Nama : {0}",nama);
Console.WriteLine("NIM : {0}",NIM);
Console.Write("Data anda sudah benar[y/t]? ");
jawab=Console.ReadLine();
Console.WriteLine("");
}
while(jawab=="t");
Console.WriteLine("Terima kasih ,{0} Anda telah terdaftar di perpustakaan POLMAN",nama);
Console.ReadLine();
}
}
}
8) Exception Handling
=====================
using System;
namespace ExceptionHandling_028
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
int umur;
START:
try
{
Console.Write("Berapa umur anda? ");
umur=Convert.ToInt32(Console.ReadLine());
}
catch
{
Console.WriteLine("Error: Input integer type data only");
Console.ReadLine();
goto START;
}
Console.WriteLine("Tipe data benar!");
Console.ReadLine();
}
}
}
Pemrograman 2: C# (C-Sharp)
Tanggal 2 Maret 2011
1) Selisih Waktu
================
using System;
namespace Selisih_waktu_028
{
public struct waktu
{
public int hh,mm,ss;
public waktu(int p1, int p2, int p3)
{
hh = p1;
mm = p2;
ss = p3;
}
}
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
waktu W1 = new waktu();
waktu W2 = new waktu();
waktu W3 = new waktu();
Console.Write("Jam awal Percakapan: ");
W1.hh=Convert.ToInt32(Console.ReadLine());
Console.Write("Menit awal Percakapan: ");
W1.mm=Convert.ToInt32(Console.ReadLine());
Console.Write("Detik awal Percakapan: ");
W1.ss=Convert.ToInt32(Console.ReadLine());
Console.Write("Jam akhir Percakapan: ");
W2.hh=Convert.ToInt32(Console.ReadLine());
Console.Write("Menit akhir Percakapan: ");
W2.mm=Convert.ToInt32(Console.ReadLine());
Console.Write("Detik akhir Percakapan: ");
W2.ss=Convert.ToInt32(Console.ReadLine());
if(W2.ss>=W1.ss)
W3.ss=W2.ss-W1.ss;
else
{
W3.ss=(W2.ss+60)-W1.ss;
W2.mm=W2.mm-1;
}
if(W2.mm>=W1.mm)
W3.mm=W2.mm-W1.mm;
else
{
W3.mm=(W2.mm+60) - W1.mm;
W2.hh=W2.hh - W1.hh;
}
W3.hh=W2.hh-W1.hh;
Console.WriteLine("Lama Percakapan adalah {0}:{1}:{2}",W3.hh,W3.mm,W3.ss);
Console.ReadLine();
}
}
}
2) Faktorial
============
using System;
namespace Faktorial_028
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
int n,k,fak;
Console.Write("masukkan angka: ");
n = Convert.ToInt32(Console.ReadLine());
if (n==0)
fak = 1;
else
{
fak=1;
for(k=1;k<=n;k++)
{
fak=fak*k;
}
}
Console.WriteLine("Faktorial dari {0} adalah {1}",n,fak);
Console.ReadLine();
}
}
}
3) Perbandingan angka
=====================
using System;
namespace Perbandingan_angka_028
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
int x,c,ulang=1,a=0;
int[] angka = new int[3];
for(x=0;x<3;x++)
{
Console.Write("Masukkan angka ke {0}: ",x+1);
angka[x]=Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("A = {0}",angka[0]);
Console.WriteLine("B = {0}",angka[1]);
Console.WriteLine("C = {0}",angka[2]);
while(ulang==1)
{
a=0;
for(x=0;x<2;x++)
{
if(angka[x]>angka[x+1])
{
c=angka[x+1];
angka[x+1]=angka[x];
angka[x]=c;
a=1;
}
}
if(a==0)
ulang=0;
}
Console.WriteLine("Bilangan terbesar adalah {0}",angka[2]);
Console.ReadLine();
}
}
}
4) Kalkulator
=============
using System;
namespace Kalkulator_028
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
int pilihan;
Console.Write("1. Penambahan\n2. Pengurangan\n3. Pembagian\n4. Perkalian\nPilih nomor: ");
pilihan = Convert.ToInt32(Console.ReadLine());
if (pilihan == 1)
{
int a,b;
Console.Write("Masukkan bilangan pertama: ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Masukkan bilangan kedua: ");
b = Convert.ToInt32(Console.ReadLine());
int c;
c = a + b;
Console.WriteLine("Angka 1: {0}",a);
Console.WriteLine("Operator (+, -, *, /) : +");
Console.WriteLine("Angka 2: {0}",b);
Console.WriteLine("Jumlah adalah {0}",c);
}
if (pilihan == 2)
{
int a,b;
Console.Write("Masukkan bilangan pertama: ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Masukkan bilangan kedua: ");
b = Convert.ToInt32(Console.ReadLine());
int c;
c = a - b;
Console.WriteLine("Angka 1: {0}",a);
Console.WriteLine("Operator (+, -, *, /) : -");
Console.WriteLine("Angka 2: {0}",b);
Console.WriteLine("Jumlah adalah {0}",c);
}
if (pilihan == 3)
{
Console.Write("Masukkan bilangan pertama: ");
double a,b;
a = Convert.ToDouble(Console.ReadLine());
Console.Write("Masukkan bilangan kedua: ");
b = Convert.ToDouble(Console.ReadLine());
double c;
c = a / b;
Console.WriteLine("Angka 1: {0}",a);
Console.WriteLine("Operator (+, -, *, /) : /");
Console.WriteLine("Angka 2: {0}",b);
Console.WriteLine("Jumlah adalah {0}",c);
}
if (pilihan == 4)
{
int a,b;
Console.Write("Masukkan bilangan pertama: ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Masukkan bilangan kedua: ");
b = Convert.ToInt32(Console.ReadLine());
int c;
c = a * b;
Console.WriteLine("Angka 1: {0}",a);
Console.WriteLine("Operator (+, -, *, /) : *");
Console.WriteLine("Angka 2: {0}",b);
Console.WriteLine("Jumlah adalah {0}",c);
}
if (pilihan>4)
{
Console.WriteLine("Anda salah memasukkan kode");
}
Console.ReadLine();
}
}
}
Windu's Miscellanous Stuff
Many miscellanous stuff here, feel free to review and download my stuff ,don't forget to follow me if you like, enjoy ;)
Jumat, 04 Maret 2011
Selasa, 25 Januari 2011
Langkah-Langkah Menginstall OS Windows 7 dan Linux Mint
2. Nyalakan komputer dan jika pelu untuk mengganti posisi drive yang anda gunakan maka buka menu BIOS anda. Dengan mengubah, startup CD/DVD drive pada posisi pertama.
4. Kemudian untuk memulai menginstal, masukkan CD/DVD Windows 7 kedalam drivenya. Lalu tekan enter, maka tampilan yang akan terlihat yaitu :
- Kemudian tampilan berikutnya adalah menunjukkan bahwa windows sedang loading untuk mulai menginstal.
- Lalu akan ada tampilan install windows 7 dan kotak dialognya berisi seperti dibawah ini. Untuk bahasa pilih English atau sesuai keinginan dan untuk Time and Currency format pilih English(US),serta Keyboard or input method pilih US. Kemudian Next.
- Lalu akan muncul tampilan untuk memulai menginstal. Klik icon Install Now.
- Windows akan segera memulai install.

Kemudian muncul kotak dialog tentang Licence. Pilih I accept lalu Next.
- Lalu muncul kotak dialog “Which type of installation do you want?”. Didalam kotak dialog ini terdapat 2 pilihan yaitu Upgrade untuk mengubah sistem windows 7 dari Windows Premium ke Windows Ultimate, sedangkan Custom (Advanced) untuk menambahkan OS pada PC jika suatu PC belum mempunyai OS. Karena komputer ini belummempunyai OS maka pilih Custom.

- Kemudian akan tampil kotak dialog “Where Do You want to Install?”. Kotak dialog ini akan menampilkan dimana kita akan menyimpan OS Win7. Didalam skenarionya pilih Partition 1:System(Disk C). Lalu Next.

Kemudian muncul kotak dialog bahwa Windows 7 sedang di install. Proses ini berjalan dalam waktu yang cukup lama.

- Setelah Proses Install mengcopy telah selesai, maka muncul kotak dialog “Windows needs to restart to continue”. Klik restart now dan tunggu beberapa detik.


- Setelah proses restart setup selesai maka muncul kotak dialog “Setup Windows”. Terdapat 2 data yang harus diisi yaitu masukkan username komputer yang digunakan isi dengan Kelompok 5 dan tipe komputer yang yang akan digunakan diisi dengan PC. Lalu Next.
- Kemudian muncul kotak dialog “Type yor Windows protect Key”. Masukkan code untuk menginstall protect key. Lalu Next.
- Kemudian muncul kotak dialog “Help protect your computer and Improve Windows automatically”. Dialog ini terdapat 3 pilihan, yaitu Use recommended settings adalah file sistem yang digunakan adalah dari Win7 tersebut. Sedangkan Install imported updates only adalah untuk menginstall file system secara online. Sedangkan Ask me later adalah melewati proses ini atau akan menanyakan lagi.
- Kemudian muncul kotak dialog “Review your time and date settings”. Kotak ini untuk mensetting waktu komputer yang dgunakan. Untuk komputer ini pilih (UTC+07.00) Bangkok, Hanoi, Jakarta. Lalu Next.
- Kemudian akan diproses dan windows 7 telah selesai di install. Keluarkan CD/DVD install Win7 dari drive.
Langkah – langkah menginstall Linux Mint (LM)
- Siapkan CD drive Linux Mint untuk menginstall.
- Jika didalam partisi sudah diaktifkan untuk menginstall OS Linux mint maka masukkan CD Linux Mint pada drive.
- Maka muncul tampilan dibawah ini. Lalu enter.
- Kemudian akan muncul kotak dialog “Welcome to Linux Mint 10 32 – bit”. Didalam kotak ini terdapat 5 pilihan. Kemudian pilih Start Linux Mint.

- Kemudian Linux Mint akan terinstall.

- kemudian masuk kedalam OS Linux Mint.

- lalu pada desktop Linux Mint terdapat install Linux Mint. Kemudian pilih install Linux Mint untuk menginstall program – program Linux Mint.
- kemudian Linux Mint akan mengcopy program file – filenya.
- kemudian pada kotak dialog tentang installation complete maka pilih Restart Now. Maka PC akan merestart dan akan memunculkan OS Linux Mint.
Langganan:
Komentar (Atom)