Rabu, 17 April 2013

Program Menghitung Rata-rata

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

main (void)
{
int a,b,c,d;
a=1;
b=0;
cout<<"masukkan n = ";
cin>>c;
cout<<"bilangan yang di cari rata rata adalah ="<<endl;
while (a<=c)
{
b=b+a;
cout<<a<<" ";
a++;
}
d=b/c;
cout<<endl<<endl<<"rata rata= "<<d;
getch();
}
Read more...
separador

Program Menampilkan Bilangan Genap

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

main (void)
{
int a;
a=1;
while (a<=20)
{
if(a%2==0)
cout<<" "<<a;
a++;
}
getch();
}
Read more...
separador

Program Menghitung Nilai Akhir Mahasiswa

//Penerimaan Mahasiswa Baru

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

void main ()
{
    int nilai_tugas , nilai_quis , nilai_uts , nilai_uas ;
   float total_nilai;
   nilai_tugas = 75 ;
   nilai_quis    = 80 ;
   nilai_uts = 78 ;
   nilai_uas = 85 ;
   total_nilai = (0.2*nilai_tugas)+(0.15*nilai_quis)+(0.3*nilai_uts)+(0.35*nilai_uas);
   cout<<"Nilai Akhir Mahasiswa"<<endl<<endl;
   cout<<"Nilai Tugas   = "<<nilai_tugas<<endl;
   cout<<"Nilai Quis    = "<<nilai_quis<<endl;
   cout<<"nilai UTS     = "<<nilai_uts<<endl;
   cout<<"Nilai UAS     = "<<nilai_uas<<endl<<endl;
   cout<<"Total Nilai   = "<<total_nilai<<endl<<endl;
   getch ();
}


Read more...
separador

Program Menghitung Gaji Karyawan

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

void main()
{
    int gaji_pokok , tunjangan , PPH ;
   gaji_pokok = 1635700 ;
   tunjangan = 0.15 * gaji_pokok ;
   PPH = 0.1*(gaji_pokok + tunjangan);
   cout<<"NIP               = 6080987501"<<endl;
   cout<<"NAMA              = BUDI UTOMO "<<endl;
   cout<<"Gaji Pokok        = "<<gaji_pokok<<endl;
   cout<<"Tunjangan         = "<<tunjangan<<endl<<endl;
   cout<<"Total Gaji Bersih = "<<((gaji_pokok + tunjangan) - PPH)<<endl;
   getch();
}
Read more...
separador

Menghitung Total Pembelian dan Diskon

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

void main()
{
char id[10], nama_barang1[30],nama_barang2[30],disc2[5];
double jumlah1, jumlah2, disc1;
double harga1, harga2, ppn, total_pembelian, total_beli1, total_beli2;
    gotoxy(15,1);cout<< "Menghitung Diskon";
gotoxy(3,3);cout<<"ID CUST";gotoxy(20,3);cout<<"= C05053";

gotoxy(3,4);cout<<"Barang yang Dibeli"; gotoxy(20,4);cout<<"=";
cin>>id;
gotoxy(3,5);cout<<"Nama Barang"; gotoxy(20,5);cout<<":";
cin>>nama_barang1;
gotoxy(3,6);cout<<"Jumlah";gotoxy(25,6);cout<<"KARDUS";gotoxy(20,6);cout<<"=";
cin>>jumlah1;
gotoxy(3,7);cout<<"Harga";  gotoxy(20,7);cout<<":"<<"Rp.";
cin>>harga1;
gotoxy(3,8);cout<<"Disc"; gotoxy(24,8);cout<<"%"; gotoxy(20,8);cout<<"=";
cin>>disc1;
gotoxy(3,9);cout<<"Nama Barang";  gotoxy(20,9);cout<<"=";
cin>>nama_barang2;
gotoxy(3,10);cout<<"Jumlah";  gotoxy(20,10);cout<<"=";
cin>>jumlah2;
gotoxy(3,11);cout<<"Harga";  gotoxy(20,11);cout<<"="<<"Rp.";
cin>>harga2;
gotoxy(3,12);cout<<"Disc";  gotoxy(20,12);cout<<"=";
cin>>disc2;
total_beli1=(disc1/100)*(jumlah1*harga1);
total_beli2= jumlah2*harga2;
ppn=0.1*(total_beli1+total_beli2);
total_pembelian=(total_beli1+total_beli2)-ppn;
gotoxy(1,13);cout<<"PPN";  gotoxy(20,13);cout<<":"<<ppn;
gotoxy(1,14);cout<<"TOTAL PEMBELIAN";  gotoxy(20,14);cout<<"="<<total_pembelian;

getch();
}
Read more...
separador

Contoh Script Menggunakan Float

#include <stdio.h>
#include <conio.h>
void main()
{

  float nilai1,nilai2,nilai3,nilai4,nilai5,nilai6;
  printf("masukkan bilangan pertama:");
  scanf("%f",&nilai1);
  printf("masukkan bilangan kedua:");
  scanf("%f",&nilai2);
  printf("masukkan bilangan ketiga:");
  scanf("%f",&nilai3);
  printf("masukkan bilangan keempat:");
  scanf("%f",&nilai4);
  printf("masukkan bilangan kelima:");
  scanf("%f",&nilai5);
  nilai6=(nilai1+nilai2+nilai3+nilai4+nilai5)/5;
  printf("\n\n rata2 adalah %f\n",nilai6);

  getch();
  }
Read more...
separador

Float & Double

//program09.cpp
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
void main()
{
  float a; a = 56.0123456789123456789;
  double b; b = 56.0123456789123456789;
 cout<<setprecision(18); //mengatur presisi tampilan
 cout<<"a = "<<a<<endl;
 cout<<"b = "<<b<<endl;
getch();
}
Read more...
separador

Menghitung Total Pembelian Menggunakan C++


#include<iostream.h>
 #include<stdio.h>
 #include<conio.h>
 #include<iomanip.h>
void main()
{
char id[10], nama_barang1[30],nama_barang2[30],disc2[5];
double jumlah1, jumlah2, disc1;
double harga1, harga2, ppn, total_pembelian, total_beli1, total_beli2;
    gotoxy(15,1);cout<< "Soal ke-tiga";
gotoxy(3,3);cout<<"ID CUST";gotoxy(20,3);cout<<":";
cin>>id;
gotoxy(3,4);cout<<"BARANG YANG DIBELI"; gotoxy(20,4);cout<<":";
gotoxy(3,5);cout<<"NAMA BARANG"; gotoxy(20,5);cout<<":";
cin>>nama_barang1;
gotoxy(3,6);cout<<"JUMLAH";gotoxy(25,6);cout<<"KARDUS";gotoxy(20,6);cout<<":";
cin>>jumlah1;
gotoxy(3,7);cout<<"HARGA";  gotoxy(20,7);cout<<":"<<"Rp.";
cin>>harga1;
gotoxy(3,8);cout<<"DISC"; gotoxy(24,8);cout<<"%"; gotoxy(20,8);cout<<":";
cin>>disc1;
gotoxy(3,9);cout<<"NAMA BARANG";  gotoxy(20,9);cout<<":";
cin>>nama_barang2;
gotoxy(3,10);cout<<"JUMLAH";  gotoxy(20,10);cout<<":";
cin>>jumlah2;
gotoxy(3,11);cout<<"HARGA";  gotoxy(20,11);cout<<":"<<"Rp.";
cin>>harga2;
gotoxy(3,12);cout<<"DISC";  gotoxy(20,12);cout<<":";
cin>>disc2;
total_beli1=(disc1/100)*(jumlah1*harga1);
total_beli2= jumlah2*harga2;
ppn=0.1*(total_beli1+total_beli2);
total_pembelian=(total_beli1+total_beli2)-ppn;
gotoxy(1,13);cout<<"PPN";  gotoxy(20,13);cout<<":"<<ppn;
gotoxy(1,14);cout<<"TOTAL PEMBELIAN";  gotoxy(20,14);cout<<":"<<total_pembelian;


gotoxy(25,17);cout<<"SELESAI.......";

getch();
}
Read more...
separador

Followers