-
Notifications
You must be signed in to change notification settings - Fork 0
/
kalkulator.cpp
42 lines (35 loc) · 897 Bytes
/
kalkulator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
using namespace std;
int main()
{
system("cls");
double bil1, bil2;
double hasil;
char opt;
cout << "Masukkan Angka Pertama: ";
cin >> bil1;
cout << "Masukkan Angka Operator [+ - / *]: ";
cin >> opt;
cout << "Masukkan Angka Kedua: ";
cin >> bil2;
switch (opt)
{
case '+':
hasil = bil1 + bil2;
break;
case '-':
hasil = bil1 - bil2;
break;
case '/':
hasil = bil1 / bil2;
break;
case '*':
hasil = bil1 * bil2;
break;
default:
cout << "Operator Yang Dimasukkan Salah!!!" << endl;
return EXIT_FAILURE;
}
cout << "Hasil Dari " << bil1 << " " << opt << " " << bil2 << " = " << hasil << endl;
return EXIT_SUCCESS;
}