how to make a simple calculator
DESCRIPTION
How to make a simple calculatorTRANSCRIPT
![Page 1: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/1.jpg)
How to make a Simple
Calculator??
Algoritma Pemrogaman
Proudly present:
![Page 2: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/2.jpg)
1st step >> Membuat Window
1. clear all;2. clc;3. 4. win1=figure(...5. 'units','points',...6. 'position',[130 190 400
200],...7. 'color',[.2 .5 .8],...8. 'menubar','none',...9. 'resize','off',...10. 'numbertitle','off',...11. 'name','Calculator');
![Page 3: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/3.jpg)
![Page 4: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/4.jpg)
2nd step>> Menambahkan title “Simple
Calculator” dan membuat frame-nya
13. frame1=uicontrol('parent',win1,...14. 'units','points',...15. 'position',[0 0 500 60],...16. 'backgroundcolor',[.8 .2 .4],...17. 'style','frame');18. 19. label1=uicontrol('parent',win1,...20. 'units','points',...21. 'position',[30 160 340 20],...22. 'backgroundcolor',[.2 .5 .8],...23. 'style','text',...24. 'string','Simple Calculator',...25. 'fontname','bubblegums',...26. 'fontsize',12,...27. 'fontweight','bold',...28. 'foregroundcolor',[0 0 0]);
![Page 5: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/5.jpg)
![Page 6: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/6.jpg)
3rd step>> Menambahkan label untuk ‘a’,’b’, dan ‘hasil’
30.label2=uicontrol('parent',win1,...31. 'units','points',...32. 'position',[ 100 140 100 15],...33. 'style','text',...34. 'string','Data-1',...35. 'fontname','arial',...36. 'fontweight','bold',...37. 'fontsize',10);38. 39.label2=uicontrol('parent',win1,...40. 'units','points',...41. 'position',[ 100 120 100 15],...42. 'style','text',...43. 'string','Data-2',...44. 'fontname','arial',...45. 'fontweight','bold',...46. 'fontsize',10);
![Page 7: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/7.jpg)
48. label3=uicontrol('parent',win1,...49. 'units','points',...50. 'position',[ 100 90 100 15],...51. 'style','text',...52. 'string','Result',...53. 'fontname',‘arial',...54. 'fontweight','bold',...55. 'fontsize',10);
![Page 8: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/8.jpg)
![Page 9: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/9.jpg)
56.edit1=uicontrol('parent',win1,...57. 'units','points',...58. 'position',[200 140 100 15],...59. 'style','edit',...60. 'string','0',...61. 'fontname','arial',...62. 'fontsize',10);63. 64.edit2=uicontrol('parent',win1,...65. 'units','points',...66. 'position',[200 120 100 15],...67. 'style','edit',...68. 'string','0',...69. 'fontname','arial',...70. 'fontsize',10);
4th step>> Membuat textbox untuk input data dan hasilnya
![Page 10: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/10.jpg)
72. edit3=uicontrol('parent',win1,...73. 'units','points',...74. 'position',[200 90 100 15],...75. 'style','edit',...76. 'string','0',...77. 'fontname','arial',...78. 'fontsize',10);
![Page 11: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/11.jpg)
![Page 12: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/12.jpg)
5th step>> Membuat button tambah
80. tomtambah=uicontrol('parent',win1,...
81. 'units','points',...
82. 'position',[30 40 80 15],...
83. 'style','pushbutton',...
84. 'callback','prosestambah',...
85. 'string','+',...
86. 'fontname','arial',...
87. 'fontsize',10);
![Page 13: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/13.jpg)
![Page 14: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/14.jpg)
6th step>> Membuat button kurang89. tomkurang=uicontrol('parent',win1,...90. 'units','points',...91. 'position',[110 40 80 15],...92. 'style','pushbutton',...93. 'callback','proseskurang',...94. 'string','-',...95. 'fontname','arial',...96. 'fontsize',10);
![Page 15: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/15.jpg)
7th step>> Membuat button kali
98. tomkali=uicontrol('parent',win1,...99. 'units','points',...100. 'position',[190 40 80 15],...101. 'style','pushbutton',...102. 'callback','proseskali',...103. 'string','*',...104. 'fontname','arial',...105. 'fontsize',10);
![Page 16: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/16.jpg)
8th step>> Membuat button bagi
107.tombagi=uicontrol('parent',win1,...108. 'units','points',...109. 'position',[270 40 80 15],...110. 'style','pushbutton',...111. 'callback','prosesbagi',...112. 'string','/',...113. 'fontname','arial',...114. 'fontsize',10);
![Page 17: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/17.jpg)
9th step>> Membuat button pangkat
116.tompangkat=uicontrol('parent',win1,...
117. 'units','points',...118. 'position',[30 20 80 15],...119. 'style','pushbutton',...120. 'callback','prosespangkat',...121. 'string','^',...122. 'fontname','arial',...123. 'fontsize',10);
![Page 18: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/18.jpg)
10th step>> Close button
125.tomtutup=uicontrol('parent',win1,...126. 'units','points',...127. 'position',[270 20 80 15],...128. 'style','pushbutton',...129. 'string','Close',...130. 'fontname',‘arial',...131. 'fontsize',10,...132. 'callback','close');
![Page 19: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/19.jpg)
![Page 20: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/20.jpg)
Why it can’t be
operated??
![Page 21: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/21.jpg)
Open new file1.%Proses Tambah2.a = str2num(get(edit1,'string'));3.b = str2num(get(edit2,'string'));4.c = a + b;5.set(edit3,'string',num2str(c)); Save dengan callback-nya
“prosestambah.m”
Membuat fungsi pada button
![Page 22: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/22.jpg)
O
pen new file
1.%
Proses Pengurangan
2.a
= str2num(get(edit1,'string'));
3.b
= str2num(get(edit2,'string'));
4.c
= a - b;
5.s
et(edit3,'string',num2str(c));
S
ave dengan callback-nya “proseskurang.m”
![Page 23: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/23.jpg)
• Open new file1.%Proses Perkalian2.a = str2num(get(edit1,'string'));3.b = str2num(get(edit2,'string'));4.c = a * b;5.set(edit3,'string',num2str(c));• Save dengan callback-nya
“proseskali.m”
![Page 24: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/24.jpg)
• Open new file1.%Proses Pembagian2.a =
str2num(get(edit1,'string'));3.b =
str2num(get(edit2,'string'));4.c = a / b;5.set(edit3,'string',num2str(c));• Save dengan callback-nya
“prosesbagi.m”
![Page 25: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/25.jpg)
• Open new file1.%Proses Perpangkatan2.a = str2num(get(edit1,'string'));3.b = str2num(get(edit2,'string'));4.c = a ^ b;5.set(edit3,'string',num2str(c));• Save dengan callback-nya
“prosespangkat.m”
![Page 26: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/26.jpg)
Enjoy your own calculator
![Page 27: How to make a simple calculator](https://reader035.vdocument.in/reader035/viewer/2022062319/55895f39d8b42a4d718b45d6/html5/thumbnails/27.jpg)
Thanks For Your Attention
Presented by:Ambar Mangesti
Dina NancyNida ShafiyantiRiska Anggraini