-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKalkulator.cs
72 lines (60 loc) · 2.24 KB
/
Kalkulator.cs
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// See https://aka.ms/new-console-template for more information
class Calculator
{
static void Main(string[] args)
{
Console.WriteLine("Kalkulator");
int angka1;
int angka2;
int pil;
int total;
Console.WriteLine("1. Penjumlahan");
Console.WriteLine("2. Pengurangan");
Console.WriteLine("3. Perkalian");
Console.WriteLine("4. Pembagian");
Console.WriteLine("Pilih menu kalkulator : ");
pil = int.Parse(Console.ReadLine());
if (pil ==1)
{
Console.WriteLine("Masukkan angka pertama :");
angka1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Masukkan angka kedua :");
angka2 = Convert.ToInt32(Console.ReadLine());
total = angka1 + angka2;
Console.WriteLine("Hasil : " + total);
}
else if (pil == 2)
{
Console.WriteLine("Masukkan angka pertama :");
angka1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Masukkan angka kedua :");
angka2 = Convert.ToInt32(Console.ReadLine());
total = angka1 - angka2;
Console.WriteLine("Hasil : " + total);
}
else if (pil == 3)
{
Console.WriteLine("Masukkan angka pertama :");
angka1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Masukkan angka kedua :");
angka2 = Convert.ToInt32(Console.ReadLine());
total = angka1 * angka2;
Console.WriteLine("Hasil : " + total);
}
else if (pil == 4)
{
Console.WriteLine("Masukkan angka pertama :");
angka1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Masukkan angka kedua :");
angka2 = Convert.ToInt32(Console.ReadLine());
total = angka1 / angka2;
Console.WriteLine("Hasil : " + total);
}
else if (pil == 5)
{
Console.WriteLine("Maaf, menu yang Anda pilih tidak tersedia");
}
Console.WriteLine("\nTekan sembarang key untuk keluar");
Console.ReadKey();
}
}