Menghitung Resistor
_______________________________________________________
#include<iostream.h>
main()
{
int pilihan;
float a,b,c,d,e,f,g,h,i,j,k;
cout<<"==================================\n";
cout<<"Program Menghitung 3 Resistor Pengganti\n";
cout<<"==================================\n";
cout<<"\n\n";
cout<<"1. Seri\n";
cout<<"2. Paralel\n";
cout<<"3. Exit\n";
cout<<"\n\n";
cout<<"==================================\n";
cout<<"\n\n";
cout<<"Masukan Pilihan Anda : " ;
cin>>pilihan;
switch (pilihan)
{
case 1:
cout<<"1. Seri\n";
cout<<"masukan R1 : ";
cin>>a;
cout<<"masukan R2 : ";
cin>>b;
cout<<"masukan R3 : ";
cin>>c;
d=a+b+c;
cout<<"jadi resistor penggantinya adalah "<<d<<endl;
break ;
case 2:
cout<<"2. Paralel\n";
cout<<"masukan R1 : ";
cin>>e;
cout<<"masukan R2 : ";
cin>>g;
cout<<"masukan R3 : ";
cin>>i;
cout<<"\n\n";
f=1/e;
cout<<"sehingga 1/R1 = "<<f<<endl;
h=1/g;
cout<<"sehingga 1/R2 = "<<h<<endl;
j=1/i;
cout<<"sehingga 1/R3 = "<<j<<endl;
k=f+h+j ;
cout<<"jadi resistor penggantinya (1/Rgab) adalah "<<k<<endl;
break;
case 3:
cout<<"3. Exit\n";
break;
default:
cout<<"pilihan anda salah\n";
}
}
_________________________________________________________
Semoga Bermanfaat (y)
No comments:
Post a Comment