/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Tugas; import java.util.Scanner; /** * * @author MOHAMMAD RAMLI * NIM : 1310651201 * Mohammad-Ramli.blogspot.com */ public class Kalkulator_consule_for { public static void main(String[] args) { Scanner input = new Scanner(System.in); int angka1, angka2; int hasil; int menu; System.out.println("Menu Pilihan : "); System.out.println("1. Perkalian"); System.out.println("2. Pembagian"); System.out.println("3. Penjumlahan"); System.out.println("4. Pengurangan"); System.out.println("0. Exit"); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.print("Inputkan pilihan menu : "); menu = input.nextInt(); for (int i = 0; i < 1;) { switch (menu) { case 1: System.out.println("Anda memilih menu perkalian"); System.out.print("Inputkan angka1: "); angka1 = input.nextInt(); System.out.print("Inputkan angka2: "); angka2 = input.nextInt(); hasil = angka1 * angka2; System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println("Hasil Perkalian " + angka1 + " dan " + angka2 + " = " + hasil); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); break; case 2: System.out.println("Anda memilih menu Pembagian"); System.out.print("Inputkan angka1: "); angka1 = input.nextInt(); System.out.print("Inputkan angka2: "); angka2 = input.nextInt(); hasil = angka1 / angka2; System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println("Hasil Pembagian " + angka1 + " dan " + angka2 + " = " + hasil); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); break; case 3: System.out.println("Anda memilih menu Penjumlahan"); System.out.print("Inputkan angka1: "); angka1 = input.nextInt(); System.out.print("Inputkan angka2: "); angka2 = input.nextInt(); hasil = angka1 + angka2; System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println("Hasil Penjumlahan " + angka1 + " dan " + angka2 + " = " + hasil); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); break; case 4: System.out.println("Anda memilih menu Pengurangan"); System.out.print("Inputkan angka1: "); angka1 = input.nextInt(); System.out.print("Inputkan angka2: "); angka2 = input.nextInt(); hasil = angka1 - angka2; System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println("Hasil Pengurangan " + angka1 + " dan " + angka2 + " = " + hasil); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); break; case 0: System.err.println("Terimakasih Telah Menggunakan Perhitungan Copaserr"); System.exit(0); break; default: System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println("Anda salah inputkan pilihan"); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); } } } }
Output
0 Komentar Sahabat:
Post a Comment
Jadilah yang pertama...