program C++

13 February 2013 12:49:34 Dibaca : 76

Program C++ Kalkulator berikut:

#include <iostream.h>
#include <conio.h>

main(){
int bil1,bil2,pil;
float hsl;
cout<<"Pilihlah menu di bawah ini :\n";
cout<<"[1] Penjumlahant\n";
cout<<"[2] Pengurangan\n";
cout<<"[3] Perkalian\n";
cout<<"Masukkan pilihan anda : ";
cin>>pil;

switch (pil)
{ case 1:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1+bil2;
cout<<"Hasil penjumlahannya = "<<hsl<<endl<<endl;
break;
case 2:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1-bil2;
cout<<"Hasil pengurangannya = "<<hsl<<endl<<endl;
break;
case 3:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1*bil2;
cout<<"Hasil perkaliannya = "<<hsl<<endl<<endl;
break;
default :
cout<<"Maaf blm terdaftar";
}
getch();
}

N,,,,,,,,,,,,,,,,,,,,llllllllllllllllllllllllllllllllll,l Program C++ Kalkulator

Diposkan oleh "indie cii cubhbee" di 05:36

Algoritma kalkulator ()

Deklarasi:

a,b,c : float { input }

hasil,hasil1 : float { output }

Deskripsi:

Read(a,b,c)

hasil=tambah  a+b

hasil=kurang  a-b

hasil=kali  a x b

hasil=bagi  a / b

hasil=per x  1 / a

hasil=pangkat * a

hasil=akar  sqrt(a)

hasil=kuadrat  a x a

hasil=kubik  a x a x a

hasil=faktorial  fak*i

hasil1=sines  sin(c)

hasil1=cosines  cos(c)

hasil1=tangen  tan(c)

Write (hasil)

Berikut programnya :

#include <iostream.h>

#include <conio.h>

#include <math.h>

#include <stdio.h>

class kalkulator {

friend istream& operator >> (istream&, kalkulator&);

friend ostream& operator << (ostream&, const kalkulator&);

public :

kalkulator();

void menu();

int tambah();

int kurang();

int kali();

float bagi();

float perx();

int pangkat();

int akar();

int kuadrat();

int kubik();

long faktorial();

void sines();

void cosines();

void tangen();

private:

float a,b,c,hasil;

};

istream& operator>>(istream& in, kalkulator& masuk){

cout<<"\t Selamat datang di program kalkulator sederhana ini \n";

cout<<"\t Selamat mencoba \n";

cout<<"\t Semoga Bermanfaat untuk Kalian \n"<<endl;

cout<<"\t ==================================== \n";

cout<<"\t | PROGRAM KALKULATOR SEDERHANA |\n";

cout<<"\t | by Indri Fitri Yadini (10018023) |\n";

cout<<"\t | UNIVERSITAS AHMAD DAHLAN |\n";

cout<<"\t ==================================== \n"<<endl;

cout<<"*********************************************\n";

cout<<"| KALKULATOR |\n";

cout<<"*********************************************\n";

cout<<"| ___ ___ ___ ___ ___ ___ ___ |\n";

cout<<"| |sin| |x^2| | / | | + | | 7 | | 8 | | 9 | |\n";

cout<<"| |___| |___| |___| |___| |___| |___| |___| |\n";

cout<<"| ___ ___ ___ ___ ___ ___ ___ |\n";

cout<<"| |cos| |x^3| |1/x| | - | | 4 | | 5 | | 6 | |\n";

cout<<"| |___| |___| |___| |___| |___| |___| |___| |\n";

cout<<"| ___ ___ ___ ___ ___ ___ ___ |\n";

cout<<"| |tan| | n!| |x^y| | * | | 1 | | 2 | | 3 | |\n";

cout<<"| |___| |___| |___| |___| |___| |___| |___| |\n";

cout<<"| ___ ___ ___ ___ ___ ___ ___ |\n";

cout<<"| |sqr| |CE | | C | | . | | 0 | |+/-| | = | |\n";

cout<<"| |___| |___| |___| |___| |___| |___| |___| |\n";

cout<<"|___________________________________________|\n"<<endl;

cout<<"1. Tambah\n";

cout<<"2. Kurang\n";

cout<<"3. Kali\n";

cout<<"4. Bagi\n";

cout<<"5. Per x\n";

cout<<"6. Pangkat\n" ;

cout<<"7. Akar\n" ;

cout<<"8. Kuadrat\n";

cout<<"9. Kubik\n";

cout<<"10. Faktorial\n";

cout<<"11. Sines\n";

cout<<"12. Cosines\n";

cout<<"13. Tangen\n";

cout<<"14. Keluar\n"<<endl;

cout<<"Masukan pilihan anda : ";

int pilihan;

cin>>pilihan;

if (pilihan==1)

{

masuk.tambah();}

else if (pilihan==2)

{

masuk.kurang();}

else if (pilihan==3)

{

masuk.kali();}

else if (pilihan==4)

{

masuk.bagi();}

else if (pilihan==5)

{

masuk.perx();}

else if (pilihan==6)

{

masuk.pangkat();}

else if (pilihan==7)

{

masuk.akar();}

else if (pilihan==8)

{

masuk.kuadrat();}

else if (pilihan==9)

{

masuk.kubik();}

else if (pilihan==10)

{

masuk.faktorial();}

else if (pilihan==11)

{

masuk.sines();}

else if (pilihan==12)

{

masuk.cosines();}

else if (pilihan==13)

{

masuk.tangen();}

else if (pilihan==14)

{

cout<<"Anda telah keluar dari program"<<endl;}

else

cout<<"Inputan Anda Salah\n";

return in;

}

ostream& operator<<(ostream& out, const kalkulator& keluar){

out<<"\t Terima Kasih....:)"<<endl;

out<<"\t :: created by indie emerald g bastian ::";

return out;}

kalkulator::kalkulator(){} //konstruktor

int kalkulator::tambah(){

cout<<"Masukan bilangan pertama : ";

cin>>a;

cout<<"Masukan bilangan kedua : ";

cin>>b;

hasil = a+b;

cout<<"Hasil tambah "<<a<<" + "<<b<<" = "<<hasil<<endl;}

int kalkulator::kurang(){

cout<<"Masukan bilangan pertama : ";

cin>>a;

cout<<"Masukan bilangan kedua : ";

cin>>b;

hasil=a-b;

cout<<"Hasil kurang "<<a<<" - "<<b<<" = "<<hasil<<endl;}

int kalkulator::kali(){

cout<<"Masukan bilangan pertama : ";

cin>>a;

cout<<"Masukan bilangan kedua : ";

cin>>b;

hasil=a*b;

cout<<"Hasil kali "<<a<<" * "<<b<<"= "<<hasil<<endl;}

float kalkulator::bagi(){

cout<<"Masukan bilangan pertama : ";

cin>>a;

cout<<"Masukan bilangan kedua : ";

cin>>b;

hasil=a/b;

cout<<"Hasil bagi "<<a<<" dan "<<b<<"= "<<hasil<<endl;}

float kalkulator::perx(){

cout<<"Masukan bilangan : ";

cin>>a;

hasil=1/a;

cout<<"Hasil 1 per x = "<<hasil<<endl;}

int kalkulator::pangkat(){

cout<<"Masukan bilangan : ";

cin>>a;

cout<<"Masukan pangkat : ";

cin>>b;

int hasil=1;

for(int i=1;i<=b;i++)

hasil*=a;

cout<<"Hasil "<<a<<" pangkat "<<b<<" = "<<hasil<<endl;}

int kalkulator::akar(){

cout<<"Masukan bilangan : ";

cin>>a;

hasil=sqrt(a);

cout<<"Hasil akar = "<<hasil<<endl;}

int kalkulator::kuadrat(){

cout<<"Masukan bilangan : ";

cin>>a;

hasil=a*a;

cout<<"Hasil kuadrat = "<<hasil<<endl;}

int kalkulator::kubik(){

cout<<"Masukan bilangan : ";

cin>>a;

hasil=a*a*a;

cout<<"Hasil kubik = "<<hasil<<endl;}

long kalkulator::faktorial(){

cout<<"Masukan bilangan : ";

cin>>a;

long fak=1;

for(int i=1;i<=a;i++)

fak=fak*i;

cout<<"Hasil "<<a<<"faktorial = "<<fak<<endl;}

void kalkulator::sines(){

cout<<"Masukkan bilangan : ";

cin>>c;

hasil = sin( c );

cout << "Hasil sin "<<c<<" = "<<hasil<<endl;}

void kalkulator::cosines(){

cout<<"Masukkan bilangan : ";

cin>>c;

hasil = cos( c );

cout << "Hasil cos "<<c<<" = "<<hasil<<endl;}

void kalkulator::tangen(){

cout<<"Masukkan bilangan : ";

cin>>c;

hasil = tan( c );

cout << "Hasil tan "<<c<<" = "<<hasil<<endl;}

int main(){

kalkulator indri;

cin>>indri;

cout<<indri;

getch();

return 0;

}

Program Kalkulator (C++)

By Acortz'08

Postado Senin, 20 Februari 2012 at 00:41

<iostream.h>
<conio.h>

void main()
{
int bil1,bil2,pil;
float hsl
cout<<"Program Kalkulator\n";
cout<<"=============== ==\n\n";

cout<<"Pilihlah menu di bawah ini :\n";
cout<<"[1] Penjumlahan\n";
cout<<"[2] Pengurangan\n";
cout<<"[3] Perkalian\n";
cout<<"[4] Pembagian\n";
cout<<"Masukkan pilihan anda : ";
cin>>pil
cout<<"\n";

switch (pil)
{
case 1:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1+bil2;
cout<<"Hasil penjumlahannya = "<<hsl<<endl<<endl;
break;
case 2:
cout<<"Input bil 1 = ;cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1-bil2;
cout<<Hasil pengurangannya = "<<hsl<<endl<<endl;
break;
case 3:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<Input bil 2 = ";cin>>bil2
hsl=bil1*bil2;
cout<<"Hasil perkaliannya = "<<hsl<endl<<endl;
break;
case 4:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1/bil2;
cout<<"Hasil pembagiannya = "<<hsl<<end<<end;
break;
default :
cout<<"Maaf belum terdaftar";

getch();
}

Output :

Program C++ Kalkulator berikut:

#include <iostream.h>
#include <conio.h>

main(){
int bil1,bil2,pil;
float hsl;
cout<<"Pilihlah menu di bawah ini :\n";
cout<<"[1] Penjumlahant\n";
cout<<"[2] Pengurangan\n";
cout<<"[3] Perkalian\n";
cout<<"Masukkan pilihan anda : ";
cin>>pil;

switch (pil)
{ case 1:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1+bil2;
cout<<"Hasil penjumlahannya = "<<hsl<<endl<<endl;
break;
case 2:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1-bil2;
cout<<"Hasil pengurangannya = "<<hsl<<endl<<endl;
break;
case 3:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1*bil2;
cout<<"Hasil perkaliannya = "<<hsl<<endl<<endl;
break;
default :
cout<<"Maaf blm terdaftar";
}
getch();
}

N,,,,,,,,,,,,,,,,,,,,llllllllllllllllllllllllllllllllll,l Program C++ Kalkulator

Diposkan oleh "indie cii cubhbee" di 05:36

Algoritma kalkulator ()

Deklarasi:

a,b,c : float { input }

hasil,hasil1 : float { output }

Deskripsi:

Read(a,b,c)

hasil=tambah  a+b

hasil=kurang  a-b

hasil=kali  a x b

hasil=bagi  a / b

hasil=per x  1 / a

hasil=pangkat * a

hasil=akar  sqrt(a)

hasil=kuadrat  a x a

hasil=kubik  a x a x a

hasil=faktorial  fak*i

hasil1=sines  sin(c)

hasil1=cosines  cos(c)

hasil1=tangen  tan(c)

Write (hasil)

Berikut programnya :

#include <iostream.h>

#include <conio.h>

#include <math.h>

#include <stdio.h>

class kalkulator {

friend istream& operator >> (istream&, kalkulator&);

friend ostream& operator << (ostream&, const kalkulator&);

public :

kalkulator();

void menu();

int tambah();

int kurang();

int kali();

float bagi();

float perx();

int pangkat();

int akar();

int kuadrat();

int kubik();

long faktorial();

void sines();

void cosines();

void tangen();

private:

float a,b,c,hasil;

};

istream& operator>>(istream& in, kalkulator& masuk){

cout<<"\t Selamat datang di program kalkulator sederhana ini \n";

cout<<"\t Selamat mencoba \n";

cout<<"\t Semoga Bermanfaat untuk Kalian \n"<<endl;

cout<<"\t ==================================== \n";

cout<<"\t | PROGRAM KALKULATOR SEDERHANA |\n";

cout<<"\t | by Indri Fitri Yadini (10018023) |\n";

cout<<"\t | UNIVERSITAS AHMAD DAHLAN |\n";

cout<<"\t ==================================== \n"<<endl;

cout<<"*********************************************\n";

cout<<"| KALKULATOR |\n";

cout<<"*********************************************\n";

cout<<"| ___ ___ ___ ___ ___ ___ ___ |\n";

cout<<"| |sin| |x^2| | / | | + | | 7 | | 8 | | 9 | |\n";

cout<<"| |___| |___| |___| |___| |___| |___| |___| |\n";

cout<<"| ___ ___ ___ ___ ___ ___ ___ |\n";

cout<<"| |cos| |x^3| |1/x| | - | | 4 | | 5 | | 6 | |\n";

cout<<"| |___| |___| |___| |___| |___| |___| |___| |\n";

cout<<"| ___ ___ ___ ___ ___ ___ ___ |\n";

cout<<"| |tan| | n!| |x^y| | * | | 1 | | 2 | | 3 | |\n";

cout<<"| |___| |___| |___| |___| |___| |___| |___| |\n";

cout<<"| ___ ___ ___ ___ ___ ___ ___ |\n";

cout<<"| |sqr| |CE | | C | | . | | 0 | |+/-| | = | |\n";

cout<<"| |___| |___| |___| |___| |___| |___| |___| |\n";

cout<<"|___________________________________________|\n"<<endl;

cout<<"1. Tambah\n";

cout<<"2. Kurang\n";

cout<<"3. Kali\n";

cout<<"4. Bagi\n";

cout<<"5. Per x\n";

cout<<"6. Pangkat\n" ;

cout<<"7. Akar\n" ;

cout<<"8. Kuadrat\n";

cout<<"9. Kubik\n";

cout<<"10. Faktorial\n";

cout<<"11. Sines\n";

cout<<"12. Cosines\n";

cout<<"13. Tangen\n";

cout<<"14. Keluar\n"<<endl;

cout<<"Masukan pilihan anda : ";

int pilihan;

cin>>pilihan;

if (pilihan==1)

{

masuk.tambah();}

else if (pilihan==2)

{

masuk.kurang();}

else if (pilihan==3)

{

masuk.kali();}

else if (pilihan==4)

{

masuk.bagi();}

else if (pilihan==5)

{

masuk.perx();}

else if (pilihan==6)

{

masuk.pangkat();}

else if (pilihan==7)

{

masuk.akar();}

else if (pilihan==8)

{

masuk.kuadrat();}

else if (pilihan==9)

{

masuk.kubik();}

else if (pilihan==10)

{

masuk.faktorial();}

else if (pilihan==11)

{

masuk.sines();}

else if (pilihan==12)

{

masuk.cosines();}

else if (pilihan==13)

{

masuk.tangen();}

else if (pilihan==14)

{

cout<<"Anda telah keluar dari program"<<endl;}

else

cout<<"Inputan Anda Salah\n";

return in;

}

ostream& operator<<(ostream& out, const kalkulator& keluar){

out<<"\t Terima Kasih....:)"<<endl;

out<<"\t :: created by indie emerald g bastian ::";

return out;}

kalkulator::kalkulator(){} //konstruktor

int kalkulator::tambah(){

cout<<"Masukan bilangan pertama : ";

cin>>a;

cout<<"Masukan bilangan kedua : ";

cin>>b;

hasil = a+b;

cout<<"Hasil tambah "<<a<<" + "<<b<<" = "<<hasil<<endl;}

int kalkulator::kurang(){

cout<<"Masukan bilangan pertama : ";

cin>>a;

cout<<"Masukan bilangan kedua : ";

cin>>b;

hasil=a-b;

cout<<"Hasil kurang "<<a<<" - "<<b<<" = "<<hasil<<endl;}

int kalkulator::kali(){

cout<<"Masukan bilangan pertama : ";

cin>>a;

cout<<"Masukan bilangan kedua : ";

cin>>b;

hasil=a*b;

cout<<"Hasil kali "<<a<<" * "<<b<<"= "<<hasil<<endl;}

float kalkulator::bagi(){

cout<<"Masukan bilangan pertama : ";

cin>>a;

cout<<"Masukan bilangan kedua : ";

cin>>b;

hasil=a/b;

cout<<"Hasil bagi "<<a<<" dan "<<b<<"= "<<hasil<<endl;}

float kalkulator::perx(){

cout<<"Masukan bilangan : ";

cin>>a;

hasil=1/a;

cout<<"Hasil 1 per x = "<<hasil<<endl;}

int kalkulator::pangkat(){

cout<<"Masukan bilangan : ";

cin>>a;

cout<<"Masukan pangkat : ";

cin>>b;

int hasil=1;

for(int i=1;i<=b;i++)

hasil*=a;

cout<<"Hasil "<<a<<" pangkat "<<b<<" = "<<hasil<<endl;}

int kalkulator::akar(){

cout<<"Masukan bilangan : ";

cin>>a;

hasil=sqrt(a);

cout<<"Hasil akar = "<<hasil<<endl;}

int kalkulator::kuadrat(){

cout<<"Masukan bilangan : ";

cin>>a;

hasil=a*a;

cout<<"Hasil kuadrat = "<<hasil<<endl;}

int kalkulator::kubik(){

cout<<"Masukan bilangan : ";

cin>>a;

hasil=a*a*a;

cout<<"Hasil kubik = "<<hasil<<endl;}

long kalkulator::faktorial(){

cout<<"Masukan bilangan : ";

cin>>a;

long fak=1;

for(int i=1;i<=a;i++)

fak=fak*i;

cout<<"Hasil "<<a<<"faktorial = "<<fak<<endl;}

void kalkulator::sines(){

cout<<"Masukkan bilangan : ";

cin>>c;

hasil = sin( c );

cout << "Hasil sin "<<c<<" = "<<hasil<<endl;}

void kalkulator::cosines(){

cout<<"Masukkan bilangan : ";

cin>>c;

hasil = cos( c );

cout << "Hasil cos "<<c<<" = "<<hasil<<endl;}

void kalkulator::tangen(){

cout<<"Masukkan bilangan : ";

cin>>c;

hasil = tan( c );

cout << "Hasil tan "<<c<<" = "<<hasil<<endl;}

int main(){

kalkulator indri;

cin>>indri;

cout<<indri;

getch();

return 0;

}

Program Kalkulator (C++)

By Acortz'08

Postado Senin, 20 Februari 2012 at 00:41

<iostream.h>
<conio.h>

void main()
{
int bil1,bil2,pil;
float hsl
cout<<"Program Kalkulator\n";
cout<<"=============== ==\n\n";

cout<<"Pilihlah menu di bawah ini :\n";
cout<<"[1] Penjumlahan\n";
cout<<"[2] Pengurangan\n";
cout<<"[3] Perkalian\n";
cout<<"[4] Pembagian\n";
cout<<"Masukkan pilihan anda : ";
cin>>pil
cout<<"\n";

switch (pil)
{
case 1:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1+bil2;
cout<<"Hasil penjumlahannya = "<<hsl<<endl<<endl;
break;
case 2:
cout<<"Input bil 1 = ;cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1-bil2;
cout<<Hasil pengurangannya = "<<hsl<<endl<<endl;
break;
case 3:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<Input bil 2 = ";cin>>bil2
hsl=bil1*bil2;
cout<<"Hasil perkaliannya = "<<hsl<endl<<endl;
break;
case 4:
cout<<"Input bil 1 = ";cin>>bil1;
cout<<"Input bil 2 = ";cin>>bil2;
hsl=bil1/bil2;
cout<<"Hasil pembagiannya = "<<hsl<<end<<end;
break;
default :
cout<<"Maaf belum terdaftar";

getch();
}

Output :

 

Kategori

  • Masih Kosong

Blogroll

  • Masih Kosong