berikut ini rumus pada c++ untuk menghitung dan menampilkan total hasil penjualan, dengan berbagai barang yang di inputkan berupa tabel hasil akhir.
_____rumus1______
#include <iostream.h>
#include <conio.h>
void main ()
{
int i;
char nbrg[30];
int jmlb;
int hgs;
int total;
cout<<”Masukkan 5 Data”;
gotoxy(2,3);cout<<”======================================================”;
gotoxy(2,4);cout<<”!”;
gotoxy(4,4);cout<<”NO”;
gotoxy(7,4);cout<<”!”;
gotoxy(9,4);cout<<”Nama Barang”;
gotoxy(23,4);cout<<”Jml Beli”;
gotoxy(21,4);cout<<”!”;
gotoxy(32,4);cout<<”!”;
gotoxy(34,4);cout<<”Hg Satuan”;
gotoxy(44,4);cout<<”!”;
gotoxy(46,4);cout<<”Total Hg”;
gotoxy(55,4);cout<<”!”;
gotoxy(2,5);cout<<”======================================================”;
for(int i=1; i<=5; i++)
{
gotoxy(4,5+i);cout<<i;
gotoxy(2,5+i);cout<<”!”;
gotoxy(7,5+i);cout<<”!”;
gotoxy(9,5+i);cin>>nbrg;
gotoxy(21,5+i);cout<<”!”;
gotoxy(26,5+i);cin>>jmlb;
gotoxy(32,5+i);cout<<”!”;
gotoxy(34,5+i);cin>>hgs;
gotoxy(44,5+i);cout<<”!”;
total=jmlb*hgs;
cout<<total<<endl;
gotoxy(55,5+i);cout<<”!”;
gotoxy(2,6+5);cout<<”=====================================================”;
}
getch();
}
______rumus2_____
#include <iostream.h>
#include <conio.h>
#include <conio.h>
void main (){
int i,n;
char nbrg[30];
int jmlb;
int hgs;
int total;
int totals;
int i,n;
char nbrg[30];
int jmlb;
int hgs;
int total;
int totals;
cout<<”Total pembayaran Barang \n”;
cout<<”Masukkan Jumlah Data: “;
cin>>n;
cout<<”Masukkan Jumlah Data: “;
cin>>n;
gotoxy(2,3);cout<<”======================================================”;
gotoxy(2,4);cout<<”|”;
gotoxy(4,4);cout<<”NO”;
gotoxy(7,4);cout<<”|”;
gotoxy(9,4);cout<<”Nama Barang”;
gotoxy(23,4);cout<<”Jumlah”;
gotoxy(21,4);cout<<”|”;
gotoxy(32,4);cout<<”|”;
gotoxy(34,4);cout<<”Harga”;
gotoxy(44,4);cout<<”|”;
gotoxy(46,4);cout<<”Total”;
gotoxy(55,4);cout<<”|”;
gotoxy(2,5);cout<<”======================================================”;
gotoxy(2,6+n);cout<<”======================================================”;
gotoxy(35,7+n);cout<<”Total”;
gotoxy(44,7+n);cout<<”:”;
gotoxy(2,4);cout<<”|”;
gotoxy(4,4);cout<<”NO”;
gotoxy(7,4);cout<<”|”;
gotoxy(9,4);cout<<”Nama Barang”;
gotoxy(23,4);cout<<”Jumlah”;
gotoxy(21,4);cout<<”|”;
gotoxy(32,4);cout<<”|”;
gotoxy(34,4);cout<<”Harga”;
gotoxy(44,4);cout<<”|”;
gotoxy(46,4);cout<<”Total”;
gotoxy(55,4);cout<<”|”;
gotoxy(2,5);cout<<”======================================================”;
gotoxy(2,6+n);cout<<”======================================================”;
gotoxy(35,7+n);cout<<”Total”;
gotoxy(44,7+n);cout<<”:”;
for(int i=1; i<=n; i++)
{
gotoxy(4,5+i);cout<<i;
gotoxy(2,5+i);cout<<”|”;
gotoxy(7,5+i);cout<<”|”;
gotoxy(9,5+i);cin>>nbrg;
gotoxy(21,5+i);cout<<”|”;
gotoxy(32,5+i);cout<<”|”;
gotoxy(26,5+i);cin>>jmlb;
gotoxy(44,5+i);cout<<”|”;
gotoxy(34,5+i);cin>>hgs;
gotoxy(55,5+i);cout<<”|”;
{
gotoxy(4,5+i);cout<<i;
gotoxy(2,5+i);cout<<”|”;
gotoxy(7,5+i);cout<<”|”;
gotoxy(9,5+i);cin>>nbrg;
gotoxy(21,5+i);cout<<”|”;
gotoxy(32,5+i);cout<<”|”;
gotoxy(26,5+i);cin>>jmlb;
gotoxy(44,5+i);cout<<”|”;
gotoxy(34,5+i);cin>>hgs;
gotoxy(55,5+i);cout<<”|”;
total=jmlb*hgs;
gotoxy(46,5+i);cout<<total;
gotoxy(45,7+n);
totals=total++;
gotoxy(35,7+n);cout<<”Total”;
gotoxy(44,7+n);cout<<”:Rp.”;cout<<totals;
}
gotoxy(46,5+i);cout<<total;
gotoxy(45,7+n);
totals=total++;
gotoxy(35,7+n);cout<<”Total”;
gotoxy(44,7+n);cout<<”:Rp.”;cout<<totals;
}
getch();
}
0 komentar:
Posting Komentar