Berikut adalah Source code nya :
01 | import java.io.*; |
02 |
03 | public class calc { |
04 |
05 | public static void main(String[] args) { |
06 |
07 | System.out.println( "cara menggunakan" ); |
08 | System.out.println( "masukan angka 1 " ); |
09 | System.out.println( "masukan angka 2 " ); |
10 | System.out.println( "tombol pilih cuma terdiri dari 1 sampai 4" ); |
11 | System.out.println( "1 untuk kali" ); |
12 | System.out.println( "2 untuk bagi" ); |
13 | System.out.println( "3 untuk tambah" ); |
14 | System.out.println( "4 untuk kurang" ); |
15 |
16 | BufferedReader m = new BufferedReader( new InputStreamReader(System.in)); |
17 | String input1 = " " ; |
18 | String input2 = " " ; |
19 | int x1,x2; |
20 | int kali,bagi,tambah,kurang; |
21 | int pilih; |
22 | System.out.println( "Masukkan Angka 1 : " ); |
23 | try{ |
24 | input1 = m.readLine(); |
25 |
26 | // System.out.println(input1); |
27 | }catch(IOException e){ |
28 | System.out.println(e); |
29 | } |
30 | System.out.println( "Masukkan angka 2: " ); |
31 | try{ |
32 | input2 = m.readLine(); |
33 | }catch(IOException e){ |
34 | System.out.println(e); |
35 | } |
36 | x1 = Integer.parseInt(input1); |
37 | x2 = Integer.parseInt(input2); |
38 |
39 | kali = x1*x2; |
40 | bagi = x1/x2; |
41 | tambah = x1+x2; |
42 | kurang = x1-x2; |
43 |
44 | String pilih2 = " " ; |
45 | System.out.println( "Masukkan angka pilihan : " + "\t" ); |
46 | try{ |
47 | pilih2 = m.readLine(); |
48 | pilih = Integer.parseInt(pilih2); |
49 | switch (pilih){ |
50 | case 1 : System.out.println( "hasilnya " + kali); break ; |
51 | case 2 : System.out.println( "hasilnya " + bagi); break ; |
52 | case 3 : System.out.println( "hasilnya " + tambah); break ; |
53 | case 4 : System.out.println( "hasilnya " + kurang); break ; |
54 | default : System.out.println( "data error" ); |
55 | } |
56 | }catch(IOException e){ |
57 | System.out.println(e); |
58 | } |
59 | } |
60 |
61 | } |
saat mencoba hilangkan nomor urutan tersebut, karena itu hanya mempermudah anda dalam pengurutan. terima kasih.
1 https://www.word-writes.com/2020/04/unsur-unsur-yang-harus-diperhatikan.html
ReplyDelete2 https://www.word-writes.com/2020/03/berbagai-keuntungan-yang-bisa-didapatkan-saat-berlangganan-magavision.html
3 https://www.word-writes.com/2020/03/8-wisata-kuliner-legendaris-di-semarang.html
4 https://www.word-writes.com/2019/06/perencanaan-perjalanan-di-amerika.html
5 https://www.word-writes.com/2019/06/hal-yang-perlu-di-persiapkan-oleh.html
6 https://www.word-writes.com/2019/06/tips-trik-mencari-hotel.html
7 https://www.word-writes.com/2019/06/tips-trik-mencari-restoran.html
8 https://www.word-writes.com/2019/06/perjalanan-ke-jepang-kemana-saja.html