#include"stdio.h"
#include"conio.h"
#include"string.h"
void main()
{
struct kursus
{
char np[10],nama[10],kue[15],harga[10];
int kd;
}k[30];
char jwb;
int no=0,co=0,ck=0,st=0,cn=0,i=0;
do
{
clrscr();
i++;
puts(" A/a = Coklat");
puts(" B/b = Coklat Keju");
puts(" C/c = Strawberry");
puts(" D/d = Coklat Kacang");
printf("\n \n \n");
printf(" data pembeli ke: %d\n",i);
puts("");
printf("masukan nama pembeli :");scanf("%s",k[i].nama);
printf("\nmasukkan kode kue bandung [A/B/C/D/a/b/c/d] :");scanf("%s",&k[i].kd);
switch (k[i].kd)
{
case 'A' :strcpy(k[i].kue,"Coklat");
strcpy(k[i].harga,"9000");
co++;
break;
case 'a' :strcpy(k[i].kue,"Coklat");
strcpy(k[i].harga,"9000");
co++;
break;
case'B' : strcpy(k[i].kue,"Coklat Keju");
strcpy(k[i].harga,"9500");
ck++;
break;
case'b' : strcpy(k[i].kue,"Coklat Keju");
strcpy(k[i].harga,"9500");
ck++;
break;
case 'C' :strcpy(k[i].kue,"strowberry");
strcpy(k[i].harga,"10000");
st++;
break;
case 'c' :strcpy(k[i].kue,"strowberry");
strcpy(k[i].harga,"10000");
st++;
break;
default :strcpy(k[i].kue,"Coklat Kacang");
strcpy(k[i].harga,"9500");
cn++;
break;
}
printf("\n\n\n Proses data lagi [Y/N]:");
jwb=getche();
}
while ((jwb=='Y')||(jwb=='y'));
clrscr();
puts(" Pondok Kue Bandung");
puts(" Semarang");
puts("===============================================================");
puts("No. Nama Pembeli Rasa Kue harga");
puts("===============================================================");
for(no=1;no<=i;no++)
{
gotoxy(1,5+no);printf("%d",no);
gotoxy(5,5+no);printf("%s",k[no].nama);
gotoxy(20,5+no);printf("%s",k[no].kue);
gotoxy(40,5+no);printf("%s",k[no].harga);
}
puts("");
puts("==============================================================");
printf("Jumlah pembeli kue bandung rasa coklat sebanyak : %3d orang\n",co);
printf("Jumlah pembeli kue bandung rasa coklat keju sebanyak : %3d orang\n",ck);
printf("Jumlah pembeli kue bandung rasa strowberry sebanyak : %3d orang\n",st);
printf("Jumlah pembeli kue bandung rasa coklat kacang sebanyak : %3d orang\n",cn);
getch();
}
#include"conio.h"
#include"string.h"
void main()
{
struct kursus
{
char np[10],nama[10],kue[15],harga[10];
int kd;
}k[30];
char jwb;
int no=0,co=0,ck=0,st=0,cn=0,i=0;
do
{
clrscr();
i++;
puts(" A/a = Coklat");
puts(" B/b = Coklat Keju");
puts(" C/c = Strawberry");
puts(" D/d = Coklat Kacang");
printf("\n \n \n");
printf(" data pembeli ke: %d\n",i);
puts("");
printf("masukan nama pembeli :");scanf("%s",k[i].nama);
printf("\nmasukkan kode kue bandung [A/B/C/D/a/b/c/d] :");scanf("%s",&k[i].kd);
switch (k[i].kd)
{
case 'A' :strcpy(k[i].kue,"Coklat");
strcpy(k[i].harga,"9000");
co++;
break;
case 'a' :strcpy(k[i].kue,"Coklat");
strcpy(k[i].harga,"9000");
co++;
break;
case'B' : strcpy(k[i].kue,"Coklat Keju");
strcpy(k[i].harga,"9500");
ck++;
break;
case'b' : strcpy(k[i].kue,"Coklat Keju");
strcpy(k[i].harga,"9500");
ck++;
break;
case 'C' :strcpy(k[i].kue,"strowberry");
strcpy(k[i].harga,"10000");
st++;
break;
case 'c' :strcpy(k[i].kue,"strowberry");
strcpy(k[i].harga,"10000");
st++;
break;
default :strcpy(k[i].kue,"Coklat Kacang");
strcpy(k[i].harga,"9500");
cn++;
break;
}
printf("\n\n\n Proses data lagi [Y/N]:");
jwb=getche();
}
while ((jwb=='Y')||(jwb=='y'));
clrscr();
puts(" Pondok Kue Bandung");
puts(" Semarang");
puts("===============================================================");
puts("No. Nama Pembeli Rasa Kue harga");
puts("===============================================================");
for(no=1;no<=i;no++)
{
gotoxy(1,5+no);printf("%d",no);
gotoxy(5,5+no);printf("%s",k[no].nama);
gotoxy(20,5+no);printf("%s",k[no].kue);
gotoxy(40,5+no);printf("%s",k[no].harga);
}
puts("");
puts("==============================================================");
printf("Jumlah pembeli kue bandung rasa coklat sebanyak : %3d orang\n",co);
printf("Jumlah pembeli kue bandung rasa coklat keju sebanyak : %3d orang\n",ck);
printf("Jumlah pembeli kue bandung rasa strowberry sebanyak : %3d orang\n",st);
printf("Jumlah pembeli kue bandung rasa coklat kacang sebanyak : %3d orang\n",cn);
getch();
}
Hasilnya Menjadi seperti ini: