Program Mencari Nilai Daya Listrik ( Dev C++ )
#include <iostream>
#include <conio.h>
#include <stdio.h>
using namespace std;
int main(void )
{
float vs,r1,r2,r3,i1,i2,i3,pr1,pr2,pr3,i,rt,hubungan;
char mengulang;
do
{
cout<<"masukan nilai vs=";cin>>vs;
cout<<"masukan nilai r1=";cin>>r1;
cout<<"masukan nilai r2=";cin>>r2;
cout<<"masukan nilai r3=";cin>>r3;
do
{
cout<<"masukan hubungan r"<<endl;
cout<<"1.seri"<<endl<<"2.paralel"<<endl;
cout<<endl<<"apa hubungannya=>";cin>>hubungan;
if (hubungan==1)
{
rt=r1+r2+r3;
i=vs/rt;
i1=i2=i3=i;
pr1=i*i*r1;
pr2=i*i*r2;
pr3=i*i*r3;
}
else if(hubungan==2)
{
i1=vs/r1;
i2=vs/r2;
i3=vs/r3;
pr1=i1*i1*r1;
pr2=i2*i2*r2;
pr3=i3*i3*r3;
}
else
cout<<endl<<"maaf hubungan anda terlarang"<<endl<<"press any key";
getch();
cout<<"i1="<<i1<<endl;
cout<<"i2="<<i2<<endl;
cout<<"i3="<<i3<<endl;
cout<<"pr1="<<pr1<<endl;
cout<<"pr2="<<pr2<<endl;
cout<<"pr3="<<pr3<<endl;
}while(hubungan<1|hubungan>2);
cout<<"anda mau mengulang (Y/T)";cin>>mengulang;
}while(mengulang=='y');
cout<<"terima kasihku untukmu";
getch();
}
Hasil Compile
No comments:
Post a Comment