You are on page 1of 2

NAMA : TRI CAHYO NUGROHO

KELAS : IFC (Tapi numpang di kelas A 2015)

NIM : 15102116

LATIHAN PRAKTIKUM MODUL 2 BUAT CALCULATOR SEDERHANA

1. SCREENSHOOT :

2. CODING :
3. using System;
4. using System.Collections.Generic;
5. using System.ComponentModel;
6. using System.Data;
7. using System.Drawing;
8. using System.Linq;
9. using System.Text;
10. using System.Threading.Tasks;
11. using System.Windows.Forms;
12.
13. namespace TugasCalculator
14. {
15. public partial class Form1 : Form
16. {
17. public Form1()
18. {
19. InitializeComponent();
20. }
21.
22. private void button1_Click(object sender, EventArgs e)
23. {
24. if ((textBox1.Text == "") || (textBox2.Text == ""))
25. { MessageBox.Show("Masukkan angka : "); }
26.
27. float a, b, c;
28.
29. a = float.Parse(this.textBox1.Text);
30. b = float.Parse(this.textBox2.Text);
31. c = a + b;
32. this.textBox3.Text = Convert.ToString(c);
33.
34. }
35. private void button2_Click(object sender, EventArgs e)
36. {
37. float a, b, c;
38.
39. a = float.Parse(this.textBox1.Text);
40. b = float.Parse(this.textBox2.Text);
41. c = a - b;
42. this.textBox3.Text = Convert.ToString(c);
43. }
44.
45. private void button3_Click(object sender, EventArgs e)
46. {
47. float a, b, c;
48.
49. a = float.Parse(this.textBox1.Text);
50. b = float.Parse(this.textBox2.Text);
51. c = a * b;
52. this.textBox3.Text = Convert.ToString(c);
53. }
54.
55. private void button4_Click(object sender, EventArgs e)
56. {
57. float a, b, c;
58.
59. a = float.Parse(this.textBox1.Text);
60. b = float.Parse(this.textBox2.Text);
61. c = a / b;
62. this.textBox3.Text = Convert.ToString(c);
63. }
64.
65. private void button5_Click(object sender, EventArgs e)
66. {
67. this.textBox1.Text = "";
68. this.textBox2.Text = "";
69. this.textBox3.Text = "";
70. }
71.
72. }
73. }

You might also like