Selasa, 24 Januari 2012

TestKaryawan

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Soal2;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 *
 * @author Eduardus Hardika Sandy A. (1053140084)
 */
public class TesKaryawan {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int tgl, bln, thn;
        String nm;

        try {
            Karyawan k = new Karyawan();

            System.out.print("Masukkan Nama : ");
            nm = input.next();
            k.setNama(nm);
            System.out.print("Masukkan Tanggal : ");
            tgl = input.nextInt();
            k.setTglLahir(tgl);
            System.out.print("Masukkan Bulan : ");
            bln = input.nextInt();
            k.setBlnLahir(bln);
            System.out.print("Masukkan Tahun : ");
            thn = input.nextInt();
            k.setThnLahir(thn);

        } catch (InputMismatchException  f) {
            System.out.println("Salah Format");
        }
        catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}

Tidak ada komentar:

Posting Komentar