Advertisement
fiqriachmada

TugasTambahanModulII

Nov 30th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.90 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. #include<stdio.h>
  5. #include<math.h>
  6.  
  7. using namespace std;
  8. int y,n;
  9. char in;
  10. bool state=true;
  11.  
  12. int main()
  13. {
  14.     while(state){
  15.     int pilih;
  16.     int x,y,i,j,k;
  17.     int a=0,b=1,c;
  18.  
  19.     cout << "\tPilih Program : " << endl;
  20.     cout << "========================================" << endl;
  21.     cout << "1. Bilangan Fibonacci"<<endl;
  22.     cout << "2. Persegi"<<endl;
  23.     cout << "3. Number To Text"<<endl;
  24.     cout << "========================================" << endl;
  25.     cout << "Masukkan pilihan anda = ";
  26.     cin >> pilih;
  27.     cout << "\n";
  28.  
  29.     cout << endl;
  30.     switch(pilih){
  31.     case 1 :
  32.  
  33.     cout<<" X = ";
  34.     cin>>x;
  35.     cout<<" Y = ";
  36.     cin>>y;
  37.  
  38.     for(i=0; i<=y-1; i++){
  39.         for(j=0; j<=((2*y)-(2*i)); j++){
  40.             cout<< " " ;}
  41.         for(k=0; k<=i; k++)
  42.         {
  43.             c=a+b; b=a; a=c;
  44.             if(i>=x-1)
  45.             {
  46.                 cout<<" ";
  47.                 cout<<" "<<c%10;
  48.                 cout<<" ";
  49.             }
  50.         }
  51.         cout<<endl;
  52.        } break;
  53.     case 2 : //kotak responsif
  54.     cout << "Masukkan angka yang diindingkan = ";
  55.     cin>>x;
  56.         for(int n=1; n<=x+3; n++){
  57.             cout<<"#";
  58.         }
  59.         cout<<endl;
  60.         for(int y=1;y<=x;y++){
  61.                 for(i=1;i<=1;i++){
  62.                     cout<<"#";
  63.                 }
  64.                 for(int j=1; j<=(x+1); j++ ){
  65.                     cout<<"-";
  66.                 }
  67.                 for(i=1;i<=1;i++){
  68.                     cout<<"#";
  69.                 }
  70.                    cout<<endl;
  71.         }
  72.             for(int n=1; n<=x+3; n++){
  73.             cout<<"#";
  74.         } break;
  75.     case 3 : string nilai;
  76.     cout << "Input : ";
  77.     cin >> nilai;
  78.     for( i = 0; i <= nilai.length(); i++)
  79.     {
  80.  
  81.         switch(nilai[i])
  82.         {
  83.         case '1' :
  84.             cout << "Satu ";
  85.             break;
  86.         case '2' :
  87.             cout << "Dua ";
  88.             break;
  89.         case '3' :
  90.             cout << "Tiga ";
  91.             break;
  92.         case '4' :
  93.             cout << "Empat ";
  94.             break;
  95.         case '5' :
  96.             cout << "Lima ";
  97.             break;
  98.         case '6' :
  99.             cout << "Enam ";
  100.             break;
  101.         case '7' :
  102.             cout << "Tujuh ";
  103.             break;
  104.         case '8' :
  105.             cout << "Delapan ";
  106.             break;
  107.         case '9' :
  108.             cout << "Sembilan ";
  109.             break;
  110.         case '0' :
  111.             cout << "Nol ";
  112.             break;
  113.         default:
  114.             break;
  115.         }
  116.     }break;
  117.     }
  118.     cout << "\n\n" << "Ulang lagi ?(y/n) -> "; cin >> in;
  119.             if(in == 'n' || in=='N'){
  120.             cout << "Terima Kasih :)" << endl;
  121.             state = false;}
  122.             else if(in == 'y' || in=='Y'){
  123.             cout << "\nOk ulang lagi\n" << endl;
  124.             state = true;}
  125.     }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement