Sabtu, 05 Maret 2011

EXCEPTION HANDLING
 

using System;

namespace exception_handling
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class tugas8
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
try
{
int n,i;
string [] nama = new string [50];
int [] nim = new int [10];
Console.Write("Input jumlah data : ");
n=Convert.ToInt32(Console.ReadLine());
for (i=1;i<=n;i++)
{
Console.WriteLine("\n Data ke-{0} :",i);
Console.WriteLine("-----------------");
Console.Write("Nama : ");
nama[i]=Console.ReadLine();
Console.Write("NIM : ");
nim[i]=Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("\n\n Nama\t\tNIM");
Console.WriteLine("---------------------------");
for (i=1;i<=n;i++)
{
Console.WriteLine(" {0}\t{1}",nama[i],nim[i]);
}
}
catch
{
Console.WriteLine("\nInputan NIM harus berupa angka...\nTerima kasih..");
}
Console.ReadLine();
}
}
}


Jika sudah dilakukan proses debugging, maka tampilannya adalah sebagai berikut :

Tidak ada komentar:

Posting Komentar