This is default featured post 1 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.
This is default featured post 2 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.
This is default featured post 3 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.
This is default featured post 4 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.
This is default featured post 5 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.
Saturday, March 5, 2011
ARRAY
MEMBACA dan MENULIS ke LAYAR
using System;
namespace membaca_n_menulis_ke_layar_0320100017
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string a,b,c,d,e,f;
Console.WriteLine("\t\t*****My Biodata*****");
Console.WriteLine("\t\t====================");
Console.Write("Nama Anda : ");
a=Convert.ToString(Console.ReadLine());
Console.Write("TTL : ");
b=Convert.ToString(Console.ReadLine());
Console.Write("Alamat : ");
c=Convert.ToString(Console.ReadLine());
Console.Write("Agama : ");
d=Convert.ToString(Console.ReadLine());
Console.Write("Hobby : ");
e=Convert.ToString(Console.ReadLine());
Console.Write("Prinsip hidup : ");
f=Convert.ToString(Console.ReadLine());
Console.WriteLine("===============================================");
Console.WriteLine("\t\t*****My Biodata*****");
Console.WriteLine("Nama saya adalah {0}",a);
Console.WriteLine(". Saya lahir di {0}",b);//menampilkan ke layar
Console.Write("Saya tinggal di {0}",c);//menampilkan ke layar
Console.Write(". Saya beragama {0}",d);//menampilkan ke layar
Console.WriteLine(" dan Hobby saya {0}",e);//menampilkan ke layar
Console.WriteLine("Yang terpenting adalah prinsip hidupku {0}",f);//menampilkan ke layar
Console.ReadLine();
}
}
}
EXCEPTION HANDLING
Program aplikasi C# untuk mengontrol kesalahan apabila user salah menginput. Secara otomatis akan menampilkan pesan eror.
using System;
namespace Exception_Handling
{
class latihan8
{
[STAThread]
static void Main(string[] args)
{
double a,b,d;
string c;
try
{
Console.Write("Angka 1 : ");
a=Convert.ToInt32(Console.ReadLine());
Console.Write("+, -,* ,/ : ");
c=Convert.ToString(Console.ReadLine());
Console.Write("Angka 2 : ");
b=Convert.ToInt32(Console.ReadLine());
switch(c)
{
case "+" : d=a+b;
Console.WriteLine("Hasilnya adalah : {0}",d);
Console.ReadLine();
break;
case "-" : d=a-b;
Console.WriteLine("Hasilnya adalah : {0}",d);
Console.ReadLine();
break;
case "*" : d=a*b;
Console.WriteLine("Hasilnya adalah : {0}",d);
Console.ReadLine();
break;
case "/" : d=a/b;
Console.WriteLine("Hasilnya adalah : {0}",d);
Console.ReadLine();
break;
default :Console.WriteLine("Tanda yang anda masukkan salah");
break;
}
}
catch//menangani apabila inputan salah
{
Console.WriteLine("Maaf Inputan Anda salah, silahkan coba lagi");
Console.ReadLine();
}
}
}
}







