#include<stdio.h> #include<conio.h> void main() { struct prod{ int i3,i5,i7,a8,a10,fx6,fx8; float sum; } cpu; struct customer{ char id[15]; struct prod cpu; } cst[30][50]; int i=0,j=0,ti3[30],ti5[30],ti7[30],ta8[30],ta10[30],tfx6[30],tfx8[30],ti=1,tj=1; float nsum=0,xsum[50],tsum=0; char ss,x; clrscr(); printf("\n 1 - Intel Core I3 3599"); printf("\n 2 - Intel Core I5 5599"); printf("\n 3 - Intel Core I7 7599"); printf("\n 4 - AMD A8 3749"); printf("\n 5 - AMD A10 4999"); printf("\n 6 - AMD FX6 5229"); printf("\n 7 - AMD FX8 7499"); printf("\n 0 - Next Customer\n"); getch(); for(i=0;i<ti;i++,ti++) { tsum=0; fflush(stdin); xsum[i]=0; printf("Customer# %d : \n",i+1); if(i>0) { printf("Finish? [Y/N]"); x=getche(); if(x=='y'||x=='Y') ti-=1; else { clrscr(); printf("Customer# %d : \n",i+1); } } printf("\tID : "); fflush(stdin); gets(cst[i][j].id); for(j=0;j<tj;j++,tj++) { printf("\tProduct #%d",j+1); R: printf("Choose : "); fflush(stdin); ss=getche(); if(ss=='1') {tsum+=3599; ti3[i]+=1; cst[i][j].cpu.i3=ti3[i];} else if(ss=='2') {tsum+=5599; ti5[i]+=1; cst[i][j].cpu.i5=ti5[i];} else if(ss=='3') {tsum+=7599; ti7[i]+=1; cst[i][j].cpu.i7=ti7[i];} else if(ss=='4') {tsum+=3749; ta8[i]+=1; cst[i][j].cpu.a8=ta8[i];} else if(ss=='5') {tsum+=4999; ta10[i]+=1; cst[i][j].cpu.a10=ta10[i];} else if(ss=='6') {tsum+=5229; tfx6[i]+=1; cst[i][j].cpu.fx6=tfx6[i];} else if(ss=='7') {tsum+=7499; tfx8[i]+=1; cst[i][j].cpu.fx8=tfx8[i];} else if(ss=='0') {tj-=1;} else goto R; cst[i][j].cpu.sum=tsum; fflush(stdin); } xsum[i]=tsum; } printf("\n\tPress any key to list... \n"); getch(); clrscr(); j=0; for(i=0;i<ti;i++) { printf("\n Customer ID %s \n",cst[i][j].id); for(j=0;j<tj;j++) { if(ti3[i]>0) { printf("\nIntel Core i3 [3599] X %d",cst[i][j].cpu.i3); } if(ti5[i]>0) { printf("\nIntel Core i5 [5599] X %d",cst[i][j].cpu.i5); } if(ti7[i]>0) { printf("\nIntel Core i7 [7599] X %d",cst[i][j].cpu.i7); } if(ta8[i]>0) { printf("\nAMD A8 [3749] X %d",cst[i][j].cpu.a8); } if(ta10[i]>0) { printf("\nAMD A10 [4999] X %d",cst[i][j].cpu.a10); } if(tfx6[i]>0) { printf("\nAMD FX6 [5299] X %d",cst[i][j].cpu.fx6); } if(tfx8[i]>0) { printf("\nAMD FX8 [7499] X %d",cst[i][j].cpu.fx8); } } printf ("TOTAL %.2f",cst[i][j].cpu.sum); } printf("\n\n\tOVERALL TOTAL : %.2f\n",xsum[i]); } |