Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <cmath>
- using namespace std;
- void satuan (int a)
- {
- if (a==1) {
- cout<<" Satu ";
- }else if (a==2) {
- cout<<" Dua ";
- }else if (a==3) {
- cout<<" Tiga ";
- }else if (a==4) {
- cout<<" Empat ";
- }else if (a==5) {
- cout<<" Lima ";
- }else if (a==6) {
- cout<<" Enam ";
- }else if (a==7) {
- cout<<" Tujuh ";
- }else if (a==8) {
- cout<<" Delapan ";
- }else if (a==9) {
- cout<<" Sembilan ";
- }else if (a==10) {
- cout<<" Sepuluh ";
- }else if (a==11) {
- cout<<" Sebelas ";
- }
- }
- void terbilang (int b){
- if (b<=11) {
- satuan(b);
- }else if((b>11) && (b<=19)){
- terbilang(b%10);
- cout<<"Belas ";
- }else if ((b>=20)&&(b<=99)) {
- terbilang(b/10);
- cout<<"Puluh";
- terbilang(b%10);
- }else if ((b>=100)&&(b<=199)) {
- cout<<"Seratus";
- terbilang(b%100);
- }else if ((b>=200)&&(b<=999)) {
- terbilang(b/100);
- cout<<"Ratus";
- terbilang(b%100);
- }else if ((b>=1000)&&(b<=1999)) {
- cout<<"Seribu";
- terbilang(b%1000);
- }else if ((b>=2000)&&(b<=9999)) {
- terbilang(b/1000);
- cout<<"Ribu";
- terbilang(b%1000);
- }else if ((b>=10000)&&(b<=99999)) {
- terbilang(b/1000);
- cout<<"Ribu";
- terbilang(b%1000);
- }else if ((b>=100000)&&(b<=999999)) {
- terbilang(b/1000);
- cout<<"Ribu";
- terbilang(b%1000);
- }else if ((b==1000000)) {
- terbilang(b/1000000);
- cout<<"Juta";
- terbilang(b%1000000);
- }else if ((b>1000000)){
- cout<<"ERROR\n";
- cout<<"nilai yang Anda masukan melampaui database aplikasi";
- }
- }
- int main()
- {
- int pilih, pilih1, c, r, k, pola,i,n,j ;
- double hasil;
- do{
- cout << ""<< endl ;
- cout<<"Menu"<<endl;
- cout<<"1. Menghitung suhu"<<endl;
- cout<<"2. Konversi"<<endl;
- cout<<"3. Pola Diamond"<<endl;
- cout<<"4. Exit"<<endl;
- cout<<"Masukkan pilihan anda: ";
- cin>>pilih;
- switch(pilih){
- case 1:
- cout << ""<< endl ;
- cout<<"Menu Menghitung suhu"<<endl;
- cout<<"1. fahrenheit ke celcius"<<endl;
- cout<<"2. fahrenheit ke reamur"<<endl;
- cout<<"3. fahrenheit ke kelvin"<<endl;
- cout<<"Masukkan pilihan anda: ";
- cin>>pilih1;
- switch(pilih1){
- case 1:
- cout<<"masukkan suhu fahrenheit "; cin>>c;
- hasil = 0.55*(c-32);
- cout << "Hasilnya adalah : " << hasil <<endl ;
- break;
- case 2:
- cout<<"masukkan suhu fahrenheit "; cin>>r;
- hasil = 0.44*(r-32);
- cout << "Hasilnya adalah : " << hasil <<endl ;
- break;
- case 3:
- cout<<"masukkan suhu fahrenheit ";cin>>k;
- hasil = 0.55*(k-32)+273.15;
- cout << "Hasilnya adalah : " << hasil <<endl ;
- break;
- }
- break;
- case 2:{
- cout << ""<< endl ;
- int nilai;
- string angka;
- cout<<"Masukkan Bilangan Anda: ";
- cin>>nilai;
- int i=1;
- while(i<=nilai){
- cout << i;
- terbilang(i);
- cout << endl;
- i++;
- }
- cout<<"\n============================\n";
- }break;
- case 3:
- cout << ""<< endl ;
- cout<<"Pola diamond"<<endl;
- cout<<"masukkan angka "<<endl; cin>>n;
- for (i=1 ; i<=n; i++)
- {
- for (j=0; j < (n-i); j++)
- cout <<" ";
- for (j=1; j<=i;j++)
- cout<<"* ";
- cout<<"\n";
- }
- for (i=2; i<=n; i++)
- {
- for (j = n-i;j<=n-2; j++)
- cout<<" ";
- {
- for (j=n-i;j>=0;j--)
- cout<<"* ";
- }
- cout<<"\n";
- }
- }
- }while(pilih!=4);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement