-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
101 lines (85 loc) · 2.93 KB
/
Program.cs
File metadata and controls
101 lines (85 loc) · 2.93 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace kalkulator
{
class Program
{
static void Main(string[] args)
{
awal:
Console.Title = "Aplikasi Kalkulator";
Console.WriteLine("Menu Kalkulator :");
Console.WriteLine("\n1. Penambahan");
Console.WriteLine("2. Pengurangan");
Console.WriteLine("3. Perkalian");
Console.WriteLine("4. Pembagian\n");
Console.WriteLine("Pilih Nomor Menu[1-4]:");
int m = int.Parse(Console.ReadLine());
if (m == 1)
{
Console.Write("Input Nilai a = ");
int a = int.Parse(Console.ReadLine());
Console.Write("Input Nilai b = ");
int b = int.Parse(Console.ReadLine());
Console.WriteLine("Hasil Penambahan {0} + {1} = {2}", a, b, penambahan(a, b));
}
else if (m == 2)
{
Console.Write("Input Nilai a = ");
int a = int.Parse(Console.ReadLine());
Console.Write("Input Nilai b = ");
int b = int.Parse(Console.ReadLine());
Console.WriteLine("Hasil Pengurangan {0} - {1} = {2}", a, b, pengurangan(a, b));
}
else if (m == 3)
{
Console.Write("Input Nilai a = ");
int a = int.Parse(Console.ReadLine());
Console.Write("Input Nilai b = ");
int b = int.Parse(Console.ReadLine());
Console.WriteLine("Hasil Perkalian {0} * {1} = {2}", a, b, perkalian(a, b));
}
else if (m == 4)
{
Console.Write("Input Nilai a = ");
int a = int.Parse(Console.ReadLine());
Console.Write("Input Nilai b = ");
int b = int.Parse(Console.ReadLine());
Console.WriteLine("Hasil Pembagian {0} / {1} = {2}", a, b, pembagian(a, b));
}
else
{
Console.WriteLine("Maaf, Menu yang Anda Pilih Tidak Tersedia\n");
}
Console.WriteLine("Apakah Anda Ingin Menggunakan Kalkulator Kembali? : Y/N");
string pilih = Console.ReadLine();
if (pilih == "Y" || pilih == "y")
{
Console.Clear();
goto awal;
}
else
Console.WriteLine("\nTekan Sembarang Tombol untuk Keluar");
Console.ReadKey();
}
static int penambahan(int a, int b)
{
return a + b;
}
static int pengurangan(int a, int b)
{
return a - b;
}
static int perkalian(int a, int b)
{
return a * b;
}
static int pembagian(int a, int b)
{
return a / b;
}
}
}