#include<stdio.h>
#include<iostream.h>
#include<conio.h>
#include <iomanip.h>
main()
{
char user[30],pass[5],input;
char jenis[15],*jns[10];
int j,i;
int stok[10],total=0;
double harga[10],tot_harga[100];
printf("Username : ");
gets(user);
printf("Password : ");
scanf("%s",pass);
if((strcmp(user,"Teknik Informatika")==0)&&(strcmp(pass,"uas")==0))
{
awal:
printf("Masukan Jumlah Barang Yang akan di beli : ");
scanf("%d",&j);
printf("A: Odol\t\t Harga=Rp.5000\n");
printf("B: Mie\t\t Harga=Rp.3000\n");
printf("C: Sabun\t Harga=Rp.2500\n");
printf("\n");
for(i=1; i<=j; i++)
{
printf("%d. Masukan Kode Barang :",i);
scanf("%s",jenis);
printf(" Jumlah : ");
scanf("%d",&stok[i]);
if(strcmp(jenis,"Odol")==0)
{
harga[i]=5000;
tot_harga[i]=harga[i]*stok[i];
jns [i]="Odol\t";
}
else if(strcmp(jenis,"Mie")==0)
{
harga[i]=3000;
tot_harga[i]=harga[i]*stok[i];
jns[i]= "Mie\t\t";
}
else if(strcmp(jenis,"Sabun")==0)
{
harga[i]=2500;
tot_harga[i]=harga[i]*stok[i];
jns[i]="Sabun\t";
}
}
printf("----------------------------------------------------------\n");
printf("No. Kode Barang Jumlah Harga Total \n");
printf("----------------------------------------------------------\n");
for(i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(4)<<i;
cout<<setiosflags(ios::left)<<setw(14)<<jns[i];
cout<<setiosflags(ios::left)<<setw(10)<<stok[i];
cout<<setiosflags(ios::left)<<setw(8)<<harga[i];
cout<<setiosflags(ios::left)<<setw(8)<<tot_harga[i];
cout<<endl;
}
printf("-------------------------------------------------------------\n");
for(i=1;i<=j;i++)
{
total=total+tot_harga[i];
}
printf("Total Belanja Adalah\t\t : %d",total);
cout<<"\nMau input data lagi [Y/T]?";cin>>input;
if(input=='y'||input=='Y')
{
system("cls"); total=0; goto awal;
}
getch();
}
else
{
printf("\nUsername & Password anda salah");
}
}
Selamat Mencobaa.... :)
#include<iostream.h>
#include<conio.h>
#include <iomanip.h>
main()
{
char user[30],pass[5],input;
char jenis[15],*jns[10];
int j,i;
int stok[10],total=0;
double harga[10],tot_harga[100];
printf("Username : ");
gets(user);
printf("Password : ");
scanf("%s",pass);
if((strcmp(user,"Teknik Informatika")==0)&&(strcmp(pass,"uas")==0))
{
awal:
printf("Masukan Jumlah Barang Yang akan di beli : ");
scanf("%d",&j);
printf("A: Odol\t\t Harga=Rp.5000\n");
printf("B: Mie\t\t Harga=Rp.3000\n");
printf("C: Sabun\t Harga=Rp.2500\n");
printf("\n");
for(i=1; i<=j; i++)
{
printf("%d. Masukan Kode Barang :",i);
scanf("%s",jenis);
printf(" Jumlah : ");
scanf("%d",&stok[i]);
if(strcmp(jenis,"Odol")==0)
{
harga[i]=5000;
tot_harga[i]=harga[i]*stok[i];
jns [i]="Odol\t";
}
else if(strcmp(jenis,"Mie")==0)
{
harga[i]=3000;
tot_harga[i]=harga[i]*stok[i];
jns[i]= "Mie\t\t";
}
else if(strcmp(jenis,"Sabun")==0)
{
harga[i]=2500;
tot_harga[i]=harga[i]*stok[i];
jns[i]="Sabun\t";
}
}
printf("----------------------------------------------------------\n");
printf("No. Kode Barang Jumlah Harga Total \n");
printf("----------------------------------------------------------\n");
for(i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(4)<<i;
cout<<setiosflags(ios::left)<<setw(14)<<jns[i];
cout<<setiosflags(ios::left)<<setw(10)<<stok[i];
cout<<setiosflags(ios::left)<<setw(8)<<harga[i];
cout<<setiosflags(ios::left)<<setw(8)<<tot_harga[i];
cout<<endl;
}
printf("-------------------------------------------------------------\n");
for(i=1;i<=j;i++)
{
total=total+tot_harga[i];
}
printf("Total Belanja Adalah\t\t : %d",total);
cout<<"\nMau input data lagi [Y/T]?";cin>>input;
if(input=='y'||input=='Y')
{
system("cls"); total=0; goto awal;
}
getch();
}
else
{
printf("\nUsername & Password anda salah");
}
}
Selamat Mencobaa.... :)
mantafff gan....
ReplyDeleteizin cb...
mmpir gan...
http://belprog.blogspot.com