/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package kalkulator;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.Scanner;
/**
*
* @author gaara
*/
public class Kalkulator {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
Scanner masuk = new Scanner(System.in);
DataInputStream msk = new DataInputStream(System.in);
int nilai_1, nilai_2, hasil;
char operator;
System.out.println("====================");
System.out.println("aplikasi kalkulator");
System.out.println("====================");
System.out.print("masukan nilai 1 : ");
nilai_1 = masuk.nextInt();
System.out.print("masukan nilai 2 : ");
nilai_2 = masuk.nextInt();
System.out.print("masukan operator : ");
operator=(char)msk.read();
if (operator == '+') {
hasil = nilai_1 + nilai_2;
System.out.println("jadi hasilnya : " + hasil);
} else {
if (operator == '-') {
hasil = nilai_1 - nilai_2;
System.out.println("jadi hasilnya : " + hasil);
} else {
if (operator == '/') {
hasil = nilai_1 / nilai_2;
System.out.println("jadi hasilnya : " + hasil);
} else {
if (operator == '*') {
hasil = nilai_1 * nilai_2;
System.out.println("jadi hasilnya : " + hasil);
} else {
System.out.println("maaf anda goblok");
}
}
}
}
}
}
Tidak ada komentar:
Posting Komentar