C++ Resistor
Minggu, 13 Juli 2014
Add Comment
#include <iostream>
#include <conio>
#include <math>
#include <stdlib>
main()
{ awal:
int a,b,c,d,e,x,i,pang,mega,kilo;
float tol,rusak;
tol=0;
rusak=0;
cout<<" ***************************************************************************"<<endl;
cout<<" * MENGHITUNG NILAI RESISTOR *"<<endl;
cout<<" ***************************************************************************"<<endl;
cout<<" * *"<<endl;
cout<<" * 1. Hitam (1-2-3-4- ) *"<<endl;
cout<<" * 2. Coklat (1-2-3-4-5) *"<<endl;
cout<<" * 3. Merah (1-2-3- -5) *"<<endl;
cout<<" * 4. Jingga (1-2-3- -5) *"<<endl;
cout<<" * 5. Kuning (1-2-3- -5) *"<<endl;
cout<<" * 6. Hijau (1-2-3-4- ) *"<<endl;
cout<<" * 7. Biru (1-2-3- - ) *"<<endl;
cout<<" * 8. Ungu (1-2-3- - ) *"<<endl;
cout<<" * 9. Abu-abu (1-2-3- - ) *"<<endl;
cout<<" * 10. Putih (1-2-3- - ) *"<<endl;
cout<<" * 11. Emas (1-2-3-4- ) *"<<endl;
cout<<" * 12. Perak (1-2-3-4- ) *"<<endl;
cout<<" * 13. Tidak berwarna (1-2-3-4- ) *"<<endl;
cout<<" * *"<<endl;
cout<<" * Masukkan nomor warna gelang (jika tidak ada masukkan '0') *"<<endl;
cout<<" * *"<<endl;
cina:
cout<<" * Masukan gelang ke 1 = "; cin>>a;
if((a<1)||(a>10)){ cout<<" Maaf Salah input"<<endl; goto cina; }
else{}
cinb:
cout<<" * Masukan gelang ke 2 = "; cin>>b;
if((b<2)||(b>10)){ cout<<" Maaf Salah input"<<endl; goto cinb; }
else{}
cinc:
cout<<" * Masukan gelang ke 3 = "; cin>>c;
if((c<1)||(c>13)){ cout<<" Maaf Salah input"<<endl; goto cinc; }
else{}
cind:
cout<<" * Masukan gelang ke 4 = "; cin>>d;
if((d==1)||(d==2)||(d==6)||(d==11)||(d==12)||(d==13)){}
else if(d==0){}
else{ cout<<" Maaf Salah input"<<endl; goto cind; }
cine:
cout<<" * Masukan gelang ke 5 = "; cin>>e;
if((e==2)||(e==3)||(e==4)||(e==5)){}
else if(e==0){}
else{ cout<<" Maaf Salah input"<<endl; goto cine; }
system("cls");
cout<<" ***************************************************************************"<<endl;
cout<<" * URUTAN WARNA *"<<endl;
cout<<" ***************************************************************************"<<endl;
cout<<" * *"<<endl;
if(a==1) {cout<<" * [ Hitam ";}
else if(a==2) {cout<<" * [ Coklat ";}
else if(a==3) {cout<<" * [ Merah ";}
else if(a==4) {cout<<" * [ Jingga ";}
else if(a==5) {cout<<" * [ Kuning ";}
else if(a==6) {cout<<" * [ Hijau ";}
else if(a==7) {cout<<" * [ Biru ";}
else if(a==8) {cout<<" * [ Ungu ";}
else if(a==9) {cout<<" * [ Abu-abu ";}
else if(a==10){cout<<" * [ Putih ";}
if(b==2) {cout<<"- Coklat ";}
else if(b==3) {cout<<"- Merah ";}
else if(b==4) {cout<<"- Jingga ";}
else if(b==5) {cout<<"- Kuning ";}
else if(b==6) {cout<<"- Hijau ";}
else if(b==7) {cout<<"- Biru ";}
else if(b==8) {cout<<"- Ungu ";}
else if(b==9) {cout<<"- Abu-abu ";}
else if(b==10){cout<<"- Putih ";}
if(c==1) {cout<<"- Hitam "; pang=1;}
else if(c==2) {cout<<"- Coklat "; pang=10;}
else if(c==3) {cout<<"- Merah "; pang=100;}
else if(c==4) {cout<<"- Jingga "; pang=1000;}
else if(c==5) {cout<<"- Kuning "; pang=10000;}
else if(c==6) {cout<<"- Hijau "; pang=100000;}
else if(c==7) {cout<<"- Biru "; pang=1000000;}
else if(c==8) {cout<<"- Ungu "; pang=10000000;}
else if(c==9) {cout<<"- Abu-abu "; pang=100000000;}
else if(c==10){cout<<"- Putih "; pang=1000000000;}
else if(c==11){cout<<"- Emas "; pang=0.1;}
else if(c==12){cout<<"- Perak "; pang=0.01;}
else if(c==13){cout<<"- Tidak Berwarna "; pang=0.001;}
if(d==1) {cout<<"- Hitam "; tol=20;}
else if(d==2) {cout<<"- Coklat "; tol=1;}
else if(d==6) {cout<<"- Hijau "; tol=5;}
else if(d==11){cout<<"- Emas "; tol=5;}
else if(d==12){cout<<"- Perak "; tol=10;}
else if(d==13){cout<<"- Tidak Berwarna "; tol=20;}
if(e==2) {cout<<"- Coklat ]"; rusak=1;}
else if(e==3) {cout<<"- Merah ]"; rusak=0.1;}
else if(e==4) {cout<<"- Jingga ]"; rusak=0.01;}
else if(e==5) {cout<<"- Kuning ]"; rusak=0.001;}
cout<<endl;
x=((a-1)*10)+(b-1)*pang;
mega=x/1000000;
kilo=x/1000;
cout<<" * [ "<<a-1<<" - "<<b-1<<" - "<<pang<<" - "<<tol<<"% - "<<rusak<<"%/1000jam ]"<<endl;
if(x>=1000000)
{ cout<<" * [ "<<mega<<" Mega Ohm - "<<tol<<"% - "<<rusak<<"%/1000jam ]"<<endl;
cout<<" * *"<<endl;
cout<<" * [ "<<mega-(mega*tol/100)<<" Mega Ohm s/d "<<mega+(mega*tol/100)<<" Mega Ohm - "<<rusak<<"%/1000jam ]"<<endl;
}
else if(x>=1000)
{ cout<<" * [ "<<kilo<<" Kilo Ohm - "<<tol<<"% - "<<rusak<<"%/1000jam ]"<<endl;
cout<<" * *"<<endl;
cout<<" * [ "<<kilo-(kilo*tol/100)<<" kilo Ohm s/d "<<kilo+(kilo*tol/100)<<" kilo Ohm - "<<rusak<<"%/1000jam ]"<<endl;
}
else if(x<1000)
{ cout<<" * [ "<<x<<" Ohm - "<<tol<<"% - "<<rusak<<"%/1000jam ]"<<endl;
cout<<" * *"<<endl;
cout<<" * [ "<<x-(x*tol/100)<<" Ohm s/d "<<x+(x*tol/100)<<" Ohm - "<<rusak<<"%/1000jam ]"<<endl;
}
cout<<" * *"<<endl;
cout<<" ***************************************************************************"<<endl;
getch();
system("cls");
goto awal;
}
#include <conio>
#include <math>
#include <stdlib>
main()
{ awal:
int a,b,c,d,e,x,i,pang,mega,kilo;
float tol,rusak;
tol=0;
rusak=0;
cout<<" ***************************************************************************"<<endl;
cout<<" * MENGHITUNG NILAI RESISTOR *"<<endl;
cout<<" ***************************************************************************"<<endl;
cout<<" * *"<<endl;
cout<<" * 1. Hitam (1-2-3-4- ) *"<<endl;
cout<<" * 2. Coklat (1-2-3-4-5) *"<<endl;
cout<<" * 3. Merah (1-2-3- -5) *"<<endl;
cout<<" * 4. Jingga (1-2-3- -5) *"<<endl;
cout<<" * 5. Kuning (1-2-3- -5) *"<<endl;
cout<<" * 6. Hijau (1-2-3-4- ) *"<<endl;
cout<<" * 7. Biru (1-2-3- - ) *"<<endl;
cout<<" * 8. Ungu (1-2-3- - ) *"<<endl;
cout<<" * 9. Abu-abu (1-2-3- - ) *"<<endl;
cout<<" * 10. Putih (1-2-3- - ) *"<<endl;
cout<<" * 11. Emas (1-2-3-4- ) *"<<endl;
cout<<" * 12. Perak (1-2-3-4- ) *"<<endl;
cout<<" * 13. Tidak berwarna (1-2-3-4- ) *"<<endl;
cout<<" * *"<<endl;
cout<<" * Masukkan nomor warna gelang (jika tidak ada masukkan '0') *"<<endl;
cout<<" * *"<<endl;
cina:
cout<<" * Masukan gelang ke 1 = "; cin>>a;
if((a<1)||(a>10)){ cout<<" Maaf Salah input"<<endl; goto cina; }
else{}
cinb:
cout<<" * Masukan gelang ke 2 = "; cin>>b;
if((b<2)||(b>10)){ cout<<" Maaf Salah input"<<endl; goto cinb; }
else{}
cinc:
cout<<" * Masukan gelang ke 3 = "; cin>>c;
if((c<1)||(c>13)){ cout<<" Maaf Salah input"<<endl; goto cinc; }
else{}
cind:
cout<<" * Masukan gelang ke 4 = "; cin>>d;
if((d==1)||(d==2)||(d==6)||(d==11)||(d==12)||(d==13)){}
else if(d==0){}
else{ cout<<" Maaf Salah input"<<endl; goto cind; }
cine:
cout<<" * Masukan gelang ke 5 = "; cin>>e;
if((e==2)||(e==3)||(e==4)||(e==5)){}
else if(e==0){}
else{ cout<<" Maaf Salah input"<<endl; goto cine; }
system("cls");
cout<<" ***************************************************************************"<<endl;
cout<<" * URUTAN WARNA *"<<endl;
cout<<" ***************************************************************************"<<endl;
cout<<" * *"<<endl;
if(a==1) {cout<<" * [ Hitam ";}
else if(a==2) {cout<<" * [ Coklat ";}
else if(a==3) {cout<<" * [ Merah ";}
else if(a==4) {cout<<" * [ Jingga ";}
else if(a==5) {cout<<" * [ Kuning ";}
else if(a==6) {cout<<" * [ Hijau ";}
else if(a==7) {cout<<" * [ Biru ";}
else if(a==8) {cout<<" * [ Ungu ";}
else if(a==9) {cout<<" * [ Abu-abu ";}
else if(a==10){cout<<" * [ Putih ";}
if(b==2) {cout<<"- Coklat ";}
else if(b==3) {cout<<"- Merah ";}
else if(b==4) {cout<<"- Jingga ";}
else if(b==5) {cout<<"- Kuning ";}
else if(b==6) {cout<<"- Hijau ";}
else if(b==7) {cout<<"- Biru ";}
else if(b==8) {cout<<"- Ungu ";}
else if(b==9) {cout<<"- Abu-abu ";}
else if(b==10){cout<<"- Putih ";}
if(c==1) {cout<<"- Hitam "; pang=1;}
else if(c==2) {cout<<"- Coklat "; pang=10;}
else if(c==3) {cout<<"- Merah "; pang=100;}
else if(c==4) {cout<<"- Jingga "; pang=1000;}
else if(c==5) {cout<<"- Kuning "; pang=10000;}
else if(c==6) {cout<<"- Hijau "; pang=100000;}
else if(c==7) {cout<<"- Biru "; pang=1000000;}
else if(c==8) {cout<<"- Ungu "; pang=10000000;}
else if(c==9) {cout<<"- Abu-abu "; pang=100000000;}
else if(c==10){cout<<"- Putih "; pang=1000000000;}
else if(c==11){cout<<"- Emas "; pang=0.1;}
else if(c==12){cout<<"- Perak "; pang=0.01;}
else if(c==13){cout<<"- Tidak Berwarna "; pang=0.001;}
if(d==1) {cout<<"- Hitam "; tol=20;}
else if(d==2) {cout<<"- Coklat "; tol=1;}
else if(d==6) {cout<<"- Hijau "; tol=5;}
else if(d==11){cout<<"- Emas "; tol=5;}
else if(d==12){cout<<"- Perak "; tol=10;}
else if(d==13){cout<<"- Tidak Berwarna "; tol=20;}
if(e==2) {cout<<"- Coklat ]"; rusak=1;}
else if(e==3) {cout<<"- Merah ]"; rusak=0.1;}
else if(e==4) {cout<<"- Jingga ]"; rusak=0.01;}
else if(e==5) {cout<<"- Kuning ]"; rusak=0.001;}
cout<<endl;
x=((a-1)*10)+(b-1)*pang;
mega=x/1000000;
kilo=x/1000;
cout<<" * [ "<<a-1<<" - "<<b-1<<" - "<<pang<<" - "<<tol<<"% - "<<rusak<<"%/1000jam ]"<<endl;
if(x>=1000000)
{ cout<<" * [ "<<mega<<" Mega Ohm - "<<tol<<"% - "<<rusak<<"%/1000jam ]"<<endl;
cout<<" * *"<<endl;
cout<<" * [ "<<mega-(mega*tol/100)<<" Mega Ohm s/d "<<mega+(mega*tol/100)<<" Mega Ohm - "<<rusak<<"%/1000jam ]"<<endl;
}
else if(x>=1000)
{ cout<<" * [ "<<kilo<<" Kilo Ohm - "<<tol<<"% - "<<rusak<<"%/1000jam ]"<<endl;
cout<<" * *"<<endl;
cout<<" * [ "<<kilo-(kilo*tol/100)<<" kilo Ohm s/d "<<kilo+(kilo*tol/100)<<" kilo Ohm - "<<rusak<<"%/1000jam ]"<<endl;
}
else if(x<1000)
{ cout<<" * [ "<<x<<" Ohm - "<<tol<<"% - "<<rusak<<"%/1000jam ]"<<endl;
cout<<" * *"<<endl;
cout<<" * [ "<<x-(x*tol/100)<<" Ohm s/d "<<x+(x*tol/100)<<" Ohm - "<<rusak<<"%/1000jam ]"<<endl;
}
cout<<" * *"<<endl;
cout<<" ***************************************************************************"<<endl;
getch();
system("cls");
goto awal;
}
0 Response to "C++ Resistor"
Posting Komentar