#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <iostream.h>
main()
{
int a, b, c, e, f, g, h, i, j;
char d;
f=10;
clrscr();
cout<<"==============================\n";
cout<<" PERHITUNGAN NILAI RESISTOR \n";
cout<<"==============================\n";
cout<<" 0 = Hitam \n";
cout<<" 1 = Coklat \n";
cout<<" 2 = Merah \n";
cout<<" 3 = Jingga \n";
cout<<" 4 = Kuning \n";
cout<<" 5 = Hijau \n";
cout<<" 6 = Biru \n";
cout<<" 7 = Ungu \n";
cout<<" 8 = Abu-abu \n";
cout<<" 9 = Putih \n";
cout<<" a = Emas \n";
cout<<" b = Perak \n";
cout<<" c = Tak berwarna \n";
cout<<"==============================\n";
cout<<" Masukkan Kode Gelang 1 = ";
cin>>a;
cout<<" Masukkan Kode Gelang 2 = ";
cin>>b;
cout<<" Masukkan Kode Gelang 3 = ";
cin>>c;
cout<<" Masukkan Kode Gelang 4 = ";
cin>>d;
e = pow(f,c);
g = a*10*e;
h = b*e;
i = g + h;
switch(d)
{
case 'a':
j = 5;
break;
case 'b':
j = 10;
break;
case 'c':
j = 20;
break;
}
cout<<"==============================\n";
cout<<" Nilai resistor adalah "<<i<<" \n";
cout<<" dengan toleransi "<<j<<"% \n";
cout<<"==============================\n";
getch();
}
Hasil dari program di atas adalah seperti ini :
Semoga bermanfaat....
3 komentar