Membuat Program Penghitung Daya Listrik Pada C++
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main ()
{
int pilihan;
float i,v,r,w,s,f;
char nama [40];
char alamat [40];
char ulang;
cout<<"Silahkan masukan nama anda : "; cin.getline(nama,40);
clrscr();
cout<<"Silahkan masukan alamat anda (co:Ketapang) : ";
cin.getline (alamat,40);
clrscr();
do
{
clrscr();
utama:
cout<<"Selamat Datang "<<nama<<"\n"<<"dengan alamat "<<alamat<<"\n"<<"dalam penghitungan DAYA kami \n\n\n";
cout<<"========================================================================="<<endl;
cout<<"|\t\t\t\tMENGHITUNG DAYA\t\t\t\t|"<<endl;
cout<<"|=======================================================================|"<<endl;
cout<<"|\tMenghitung Daya Jika yang Diketahui nilainya adalah : \t\t|"<<endl;
cout<<"|\t1. Kuat Arus (I) dan Tegangan (V)\t\t\t\t|"<<endl;
cout<<"|\t2. Kuat Arus (I) dan Resonansi (R)\t\t\t\t|"<<endl;
cout<<"|\t3. Usaha (W) dan Waktu (s)\t\t\t\t\t|"<<endl;
cout<<"|\t4. Gaya (F) dan Tegangan Listrik (V)\t\t\t\t|"<<endl;
cout<<"|\t5. Rumus-rumus Daya\t\t\t\t\t\t|"<<endl;
cout<<"|\t0. Tidak Menemui Pilihan\t\t\t\t\t|"<<endl;
cout<<"========================================================================="<<endl;
cout<<"\n";
cout<<"\tTentukan pilihan = ";
cin>>pilihan;
clrscr();
if(pilihan==1)
{
cout<<"\t\t Menghitung Daya Jika Yang Diketahui"<<endl;
cout<<"\t\t\tKuat Arus dan Tegangan"<<endl;
cout<<"====================================================================="<<endl;
cout<<"\n\tMasukan nilai Kuat Arus = ";
cin>>i;
cout<<"\tMasukan nilai Tegangan = ";
cin>>v;
cout<<"\n====================================================================="<<endl;
cout<<"\n\t\tDaya = Tegangan x Kuat Arus"<<endl;
cout<<"\t\tP =\t V\tx\tI"<<endl;
cout<<"\t\tP =\t "<<v<<"\tx\t"<<i<<endl;
cout<<"\t\tP =\t"<<v*i<<" Watt\n";
cout<<"\n====================================================================="<<endl;
}
else if(pilihan==2)
{
cout<<"\t\t Menghitung Daya Jika Yang Diketahui"<<endl;
cout<<"\t\t\tKuat Arus dan Resonansi"<<endl;
cout<<"====================================================================="<<endl;
cout<<"\n\tMasukan nilai Kuat Arus = ";
cin>>i;
cout<<"\tMasukan nilai Resonansi = ";
cin>>r;
cout<<"\n====================================================================="<<endl;
cout<<"\n\t\tDaya = Kuat Arus x Kuat Arus x Resonansi"<<endl;
cout<<"\t\tP =\t I x I x\t R"<<endl;
cout<<"\t\tP =\t "<<i<<" x "<<i<<" x "<<r<<endl;
cout<<"\t\tP =\t "<<i*i*r<<" Watt"<<endl;
cout<<"\n====================================================================="<<endl;
}
else if(pilihan==3)
{
cout<<"\t\t Menghitung Daya Jika Yang Diketahui"<<endl;
cout<<"\t\t\tUsaha dan Waktu"<<endl;
cout<<"====================================================================="<<endl;
cout<<"\n\tMasukan nilai Usaha = ";
cin>>w;
cout<<"\tMasukan nilai Waktu = ";
cin>>s;
cout<<"\n====================================================================="<<endl;
cout<<"\n\t\tDaya = Usaha : Waktu"<<endl;
cout<<"\t\tP =\t W :\tt"<<endl;
cout<<"\t\tP =\t "<<w<<" :\t"<<s<<endl;
cout<<"\t\tP =\t "<<w/s<<" Watt"<<endl;
cout<<"\n====================================================================="<<endl;
}
else if(pilihan==4)
{
cout<<"\t\t Menghitung Daya Jika Yang Diketahui"<<endl;
cout<<"\t\t\tGaya dan Tegangan Listrik"<<endl;
cout<<"====================================================================="<<endl;
cout<<"\n\tMasukan nilai Gaya = ";
cin>>f;
cout<<"\tMasukan nilai Tegangan = ";
cin>>v;
cout<<"\n====================================================================="<<endl;
cout<<"\n\t\tDaya = Gaya x Tegangan"<<endl;
cout<<"\t\tP =\t F x\tV"<<endl;
cout<<"\t\tP =\t "<<f<<" x\t"<<v<<endl;
cout<<"\t\tP =\t "<<f*v<<" Watt"<<endl;
cout<<"\n====================================================================="<<endl;
}
else if(pilihan==5)
{
cout<<"\t\t\t\tRUMUS-RUMUS"<<endl;
cout<<"\t\t\t\t DAYA"<<endl;
cout<<"====================================================================="<<endl;
cout<<" Daya ada dalam berbagai aplikasi."<<endl;
cout<<" Daya listrik, \n\tP = VxI = I^2xR"<<endl;
cout<<" Daya poros yang berputar, \n\tP = TxO = FxV"<<endl;
cout<<" Daya aliran Fluida, \n\tP = FxV = mdot*V*V = mdotxV^2 = AVpxV^2 = ApV^3\n"<<endl;
cout<<"====================================================================="<<endl;
cout<<"====================================================================="<<endl;
cout<<" Penjelasan :"<<endl;
cout<<" mdot = laju aliran massa (kg/s)"<<endl;
cout<<" A = luas penampang aliran"<<endl;
cout<<" V = kecepatan (m/s)"<<endl;
cout<<" p = massa jenis (kg/m^3)"<<endl;
cout<<" O = kecepatan sudut (rad/s)"<<endl;
cout<<" I = Arus listrik (A)"<<endl;
cout<<" R = hambatan listrik (Ohm)"<<endl;
cout<<" V = tegangan listrik (Volt)"<<endl;
cout<<" F = gaya (N)"<<endl;
cout<<" Dan berbagai jenis lainnya. Selama ada perubahan energi terhadap waktu,"<<endl;
cout<<" maka hal tersebut bisa dipandang sebagai daya untuk sistem tersebut"<<endl;
cout<<" dE/dt = P"<<endl;
cout<<"\n====================================================================="<<endl;
}
else if(pilihan==0)
{
cout<<"\n\n\n\n\n\n\n==========================================================================="<<endl;
cout<<"\n\t\t\t\tMOHON MAAF!"<<endl;
cout<<"\t\tSISTEM KAMI BELUM DAPAT MENEMUI KEINGINAN ANDA"<<endl;
cout<<"\n==========================================================================="<<endl;
clrscr();
}
else
{
cout<<"Maaf, keyword yang anda masukan salah!\nSilahkan coba lagi!\n\nSilahkan tekan enter!"<<endl;
getch();
}
cout<<"Apakah anda ingin mencoba lagi? [y/t] ";
cin>>ulang;
}
while (ulang=='y'||ulang=='Y');
clrscr();
cout<<"TERIMA KASIH TELAH MENGGUNAKAN JASA KAMI ^-^"<<endl;
}
Halo, adakah dalam bentuk flowchartnya? Terima kasih
BalasHapus