Minggu, 24 April 2011

contoh program dengan menggunakan scanner

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

package javaapplication10;
import java.util.Scanner;

/**
 *
 * @author mcc
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner input = new Scanner (System.in);
        String nama, npm, jurusan;
        Double tgs, uas, rata2;
        System.out.print("npm = ");
        npm = input.next();
        System.out.print("nama = ");
        nama = input.next();
        System.out.print("jurusan = ");
        jurusan = input.next();
        System.out.print("input tugas = ");
        tgs = input.nextDouble();
        System.out.print("input uas = ");
        uas = input.nextDouble();
        rata2 = (tgs +uas) / 2;
        System.out.println("rata-ratanya = " +rata2);
    }
}

Tidak ada komentar:

Posting Komentar