Advertisement
agusbd

moon

Nov 17th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <stdlib.h>
  4. int hasil;
  5. using namespace std;
  6. void kali(){
  7.  
  8. int i,x;
  9. cout<<"input:"; cin>>i;
  10. for (int a=1;a<=i;a++){
  11. for (int b=1;b<=i;b++){
  12. x=a*b;
  13. cout<<setw(4)<<x<<" "<<setw(4);;
  14. }
  15. cout<<endl;
  16.  
  17. }}
  18. void pangkat(){
  19. int basis,pangkat,b;
  20. cout<<"basis:";cin>>basis;
  21. b=basis;
  22. cout<<"pangkat:";cin>>pangkat;
  23. for(int i=1;i<pangkat;i++){
  24. b=b*basis;
  25. }cout<<"hasil :\n"<<b;
  26. hasil=b;
  27. }
  28.  
  29.  
  30. void satuan (int a)
  31. {
  32. if (a==1) {
  33. cout<<" Satu ";
  34. }
  35. else if (a==2) {
  36. cout<<" Dua ";
  37. }
  38. else if (a==3) {
  39. cout<<" Tiga ";
  40. }
  41. else if (a==4) {
  42. cout<<" Empat ";
  43. }
  44. else if (a==5) {
  45. cout<<" Lima ";
  46. }
  47. else if (a==6) {
  48. cout<<" Enam ";
  49. }
  50. else if (a==7) {
  51. cout<<" Tujuh ";
  52. }
  53. else if (a==8) {
  54. cout<<" Delapan ";
  55. }
  56. else if (a==9) {
  57. cout<<" Sembilan ";
  58. }
  59. else if (a==10) {
  60. cout<<" Sepuluh ";
  61. }
  62. else if (a==11) {
  63. cout<<" Sebelas ";
  64. }}
  65. void terbilang (int b)
  66. {
  67. if (b<=11) {
  68. satuan(b);
  69. }
  70. else if ((b>11) && (b<=19)) {
  71. terbilang(b%10);
  72. cout<<"Belas ";
  73. }
  74. else if ((b>=20)&&(b<=99)) {
  75. terbilang(b/10);
  76. cout<<"Puluh";
  77. terbilang(b%10);
  78. }
  79. else if ((b>=100)&&(b<=199)) {
  80. cout<<"Seratus";
  81. terbilang(b%100);
  82. }
  83. else if ((b>=200)&&(b<=999)) {
  84. terbilang(b/100);
  85. cout<<"Ratus";
  86. terbilang(b%100);
  87. }
  88. else if ((b>=1000)&&(b<=1999)) {
  89. cout<<"Seribu";
  90. terbilang(b%1000);
  91. }
  92. else if ((b>=2000)&&(b<=9999)) {
  93. terbilang(b/1000);
  94. cout<<"Ribu";
  95. terbilang(b%1000);
  96. }}
  97.  
  98.  
  99. main(){
  100. char ulang;
  101. bool a=false;
  102. int i;
  103. do{
  104. cout<<"MENU\n";
  105. cout<<"1.PERULANGAN\n2.PEMANGKATAN\n3.HASIL PEMANGKATAN\n4.Exit\n";
  106. cout<<"PILIH :";cin>>i;
  107. switch (i){
  108.  
  109. case 1:
  110. kali();
  111. break;
  112. case 2:
  113. pangkat();
  114. a=true;
  115. break;
  116. case 3:
  117. cout<<"Hasil Pemangkatan\n";
  118. if (a==false)
  119. cout<<"pilih dua dulu";
  120. else
  121. {if (hasil==0)
  122. cout<<"Nol\n";
  123. else
  124. {
  125. terbilang(hasil);
  126. }
  127.  
  128.  
  129. }
  130. break;
  131. case 4 :
  132. exit(0);
  133. }
  134. cout<<"\nKembali ke Menu?[y/n]:";cin>>ulang;}
  135. while (ulang=='y' || ulang=='Y');
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement