Breaking News

Laman

Selasa, 03 April 2012

Modul IV Operating Conditions

This program is a collection of examples of application of the operating conditions in C + +, I hope this can be useful.
Quadratic equation program that is able to determine the rational numbers and real
#include <iostream.h>
#include <math.h>
#include <conio.h>
#include <conio.h>
void main()

{
double a , b , c ;
double d , x1 , x2 , re , im ;
cout<<"=============================================\n";
cout<<"     Menentukan Akar Persaman Kuadrat\n";
cout<<"=============================================\n";
cout<<"\n";
cout<<"bentuk umum dari persaman kuadrat : ax^2 + bx + c = 0\n";
cout<<"masukkan nilai a : ";
cin>>a;
cout<<"masukkan nilai b : ";
cin>>b;
cout<<"masukkan nilai c : ";
cin>>c;
cout<<"dari nilai yang anda masukkan kita dapat membuat persamaan kuadrat :\n";
cout<<a<<"x^2 + ("<<b<<")x + ("<<c<<") = 0\n ";
d = b*b-4*a*c;
if (d>0)
{
x1 = (-b + sqrt(d)) / (2*a);
x2 = (-b - sqrt(d)) / (2*a);
cout<<"akar-akarnya nyata/real : \n";
cout<<"Bukti :"<<x1<<"="<<"("<<-b<<"+"<<"sqrt("<<d<<")) / (2 *"<<a;
cout<<"Maka x1 = " <<x1 <<endl;
cout<<"Bukti :"<<x2<<"="<<"("<<-b<<"-"<<"sqrt("<<d<<")) / (2 *"<<a;
cout<<"Maka x2 = " <<x2 <<endl;
}
else
if (d ==0)
{
//x1 = -b / (2*a);
//x2 = x1 ;
x1 = (-b + sqrt(d)) / (2*a);
x2 = (-b - sqrt(d)) / (2*a);
cout<<"Akar kembar dan nyata/real: \n";
cout<<"Bukti :"<<x1<<"="<<"("<<-b<<"+"<<"sqrt("<<d<<")) / (2 *"<<a;
cout<<"x1 = " <<x1 <<endl;
cout<<"Bukti :"<<x2<<"="<<"("<<-b<<"-"<<"sqrt("<<d<<")) / (2 *"<<a;
cout<<"x2 = " <<x2 <<endl;
}
else
{
re = -b / (2*a);
im = sqrt(fabs(d))/(2*a);
cout<<"akar-akar imajiner :\n";
cout<<"x1 = " <<re << "+" <<im<<endl;
cout<<"x2 = " <<re << "-" <<im<<endl;
cout<<"sqrt("<<d<<") = "<<im;
}
getch();
}
Program for the provision of grade.
#include <iostream.h>
#include <conio.h>
void main()
{
float pj, pisb, pis1, pis2, ipsb, ips1, ips2, ipab, ipa1, ipa2,
sdasb, sdas1, sdas2, pg, tot;
cout<<"1. IPA";  cout<<"   ";     cout<<"2. IPS";
cout<<"\nMasukkan Pilihan Jurusan :";
cin>>pj;
if (pj == 1)
{
cout<<"Pisikologi :";
cout<<"\nMasukkan Jumlah Soal Benar :";
cin>>pis1;
cout<<"\nMasukkan Jumlah Soal Salah :";
cin>>pis2;
cout<<"\nDasar :";
cout<<"\nMasukkan Jumlah Soal Benar :";
cin>>sdas1;
cout<<"\nMasukkan Jumlah Soal Salah :";
cin>>sdas2;
cout<<"\nIPA :";
cout<<"\nMasukkan Jumlah Soal Benar :";
cin>>ipa1;
cout<<"\nMasukkan Jumlah Soal Salah :";
cin>>ipa2;
pisb=(pis1*4)-(pis2*1);
sdasb=(sdas1*4)-(sdas2*1);
ipab=(ipa1*4)-(ipa2*1);
tot= pisb+sdasb+ipab;
pg=tot/190 * 100 / 4;
cout<<"===========================================";
cout<<"\n No : Kategori                 :  Nilai  :";
cout<<"\n===========================================";
cout<<"\n 1  : Pisikologi               :   "<<pisb<<"   :";
cout<<"\n 2  : Soal Dasar               :   "<<sdasb<<"   :";
cout<<"\n 3  : IPA                      :   "<<ipab<<"   :";
cout<<"\n===========================================";
if(pg >= 45)
{
cout<<"\nSelamat Grade anda             :   "<<pg<<"%"<<"  :";
cout<<"\n===========================================";
cout<<"\nSlamat Anda Memenuhi Grade yang Ditentukan !!";
}
else
{
cout<<"\nSelamat Grade anda             :   "<<pg<<"%"<<"  :";
cout<<"\n===========================================";
cout<<"\n       Maaf Anda Tidak Memenuhi Grade !!!   ";
}
}
if (pj == 2)
{
cout<<"Pisikologi :";
cout<<"\nMasukkan Jumlah Soal Benar :";
cin>>pis1;
cout<<"\nMasukkan Jumlah Soal Salah :";
cin>>pis2;
cout<<"\nDasar :";
cout<<"\nMasukkan Jumlah Soal Benar :";
cin>>sdas1;
cout<<"\nMasukkan Jumlah Soal Salah :";
cin>>sdas2;
cout<<"\nIPS :";
cout<<"\nMasukkan Jumlah Soal Benar :";
cin>>ips1;
cout<<"\nMasukkan Jumlah Soal Salah :";
cin>>ips2;
pisb=(pis1*4)-(pis2*1);
sdasb=(sdas1*4)-(sdas2*1);
ipsb=(ips1*4)-(ips2*1);
tot= pisb+sdasb+ipsb;
pg=tot/190 * 100 / 4;
cout<<"===========================================";
cout<<"\n No : Kategori                 :  Nilai  :";
cout<<"\n===========================================";
cout<<"\n 1  : Pisikologi               :   "<<pisb<<"   :";
cout<<"\n 2  : Soal Dasar               :   "<<sdasb<<"   :";
cout<<"\n 3  : IPS                      :   "<<ipsb<<"   :";
cout<<"\n===========================================";
if(pg >= 40)
{
cout<<"\nSelamat Grade anda             :   "<<pg<<"%"<<"  :";
cout<<"\n===========================================";
cout<<"\nSlamat Anda Memenuhi Grade yang Ditentukan !!";
}
else
{
cout<<"\nSelamat Grade anda             :   "<<pg<<"%"<<" :";
cout<<"\n===========================================";
cout<<"\n       Maaf Anda Tidak Memenuhi Grade !!!   ";
}
}
getch();
}

Tidak ada komentar:

Designed By