Advertisement
fajar7xx

kode

Jan 25th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace cekNim
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string nama, nim;
  14.             try
  15.             {
  16.                 Console.Write("NIM  = ");
  17.                 nim = Console.ReadLine();
  18.                 if (nim.Trim().Length <= 0)
  19.                     throw new Exception("NIM tidak boleh kosong");
  20.                 else if (nim.Trim().Length < 9 || nim.Trim().Length <9)
  21.                     throw new Exception("NIM Maksimum 9 digit");
  22.  
  23.                 Console.Write("Nama = ");
  24.                 nama = Console.ReadLine();
  25.                 if (nama.Trim().Length <= 0)
  26.                     throw new Exception("Nama Mahasiswa tidak boleh kosong");
  27.                 else if (nama.Trim().Length > 100)
  28.                     throw new Exception("Nama Mahasiswa maksimum 100 karakter");
  29.  
  30.                 Console.WriteLine("/nMahasiswa dengan NIM = {0} Bernama {1)", nim, nama);
  31.             }
  32.             catch(Exception e)
  33.             {
  34.                 Console.WriteLine("ERROR : {0}", e.Message);
  35.             }
  36.  
  37.  
  38.  
  39.  
  40.             Console.ReadKey();
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement