1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#include<stdio.h>
#include<stdlib.h>
#pragma warning(disable:4996)
#define packageA 24.50
#define packageB 26.00
void menu(void);
int main()
{
menu();
return 0;
}
void menu(void)
{
char package = 0, yesno;
int QsA = 0, QsB = 0, qtyA = 0, qtyB = 0, q = 0, Totalqty;
float SaA=0, SaB=0, pA, pB, Totalamount;
do {
do {
printf(" Package A, B (X=exit): ");
scanf(" %c", &package);
if (package == 'A' || package == 'B' || package == 'X') {
if (package == 'A' || package == 'B') {
printf(" Quantity : ");
scanf(" %d", &q);
}
if (package == 'A') {
qtyA = q;
}
else if (package == 'B') {
qtyB = q;
}
else {
q = 0;
}
}
else {
puts("Invalid package");
}
} while (package == 'A' || package == 'B');
if (package == 'X') {
const float pA = qtyA * 24.50f;
const float pB = qtyB * 26.00f;
if (package == 'A') {
printf("\nPackage A : % d @ RM24.50 = RM % 6.2f", qtyA, pA);
}
if (package == 'B') {
printf("\nPackage B : % d @ RM26.00 = RM % 6.2f", qtyB, pB);
}
else {
if (qtyA)
printf("\nPackage A: %d @ RM24.50 = RM %6.2f", qtyA, pA);
if (qtyB)
printf("\nPackage B: %d @ RM26.00 = RM %6.2f", qtyB, pB);
printf(" Next customer (Y=yes?) : ");
scanf(" %c", &yesno);
}
}
} while (yesno == 'Y' || yesno == 'y');
if (yesno = 'N' || yesno == 'n')
{
QsA = QsA + qtyA;
SaA = QsA * packageA;
QsB = QsB + qtyB;
SaB = QsB * packageB;
Totalqty = QsA + QsB;
Totalamount = SaA + SaB;
printf("\n");
printf(" DAILY SALES SUMMARY REPORT \n");
printf("PACKAGE\t\tQuantity Sold\tSales Amount\n");
printf(" A\t\t%d\t\t%-0.2f\n", QsA, SaA);
printf(" B\t\t%d\t\t%-0.2f\n", QsB, SaB);
printf("========\t==============\t============\n");
printf(" TOTAL\t\t%d\t\t%-0.2f\n", Totalqty, Totalamount);
}
}
|