Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

My calculation bill of first customer will run into second customer's bill.. Can someone please help me.. Thankyou!!

0 votes
asked Aug 9, 2018 by ZQin
#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<ctype.h>

#pragma warning (disable:4996)

#define SST 0.1

#define COMBO_A 10.00

#define COMBO_B 15.00

#define COMBO_C 18.00

#define COMBO_D 24.00

void main()

{

// declare variable

char comboA, comboB, comboC, comboD;

char comboChoices, yesOrNo;

int quantityA = 0, quantityB = 0, quantityC = 0, quantityD = 0;

int customer = 0, totalQuantity;

int quantity = 0;

double price = 0, priceA = 0, priceB = 0, priceC = 0, priceD = 0;

double chargesA = 0, chargesB = 0, chargesC = 0, chargesD = 0;

double total = 0, totalCOMBO = 0, totalSST = 0, totalPAY = 0, ChangeDUE = 0;

double amountPAID = 0, charges = 0;

double  totalSSTCharges, totalAmountCollected;

do {

rewind(stdin);

printf("\n");

printf("       Please choose your COMBO : ");

scanf("%c", &comboChoices);

rewind(stdin);

totalCOMBO = 0;

printf("       Quantity of COMBO %c : ", comboChoices);

rewind(stdin);

scanf("%d", &quantity);

rewind(stdin);

if (toupper(comboChoices) == 'A') {

printf("\n");

priceA = COMBO_A * quantity;

printf("       Combo A : %d * RM%.2f = RM%.2f \n", quantity, COMBO_A, priceA);

quantityA += quantity;

priceA += price;

chargesA =  charges + priceA;

printf("\n");

}

else if (toupper(comboChoices) == 'B') {

printf("\n");

priceB = COMBO_B * quantity;

printf("       Combo B : %d * RM%.2f = RM%.2f \n", quantity, COMBO_B, priceB);

quantityB += quantity;

priceB += price;

chargesB = charges + priceB;

printf("\n");

}

else if (toupper(comboChoices) == 'C') {

printf("\n");

priceC = COMBO_C * quantity;

printf("       Combo C : %d * RM%.2f = RM%.2f \n", quantity, COMBO_C, priceC);

quantityC += quantity;

priceC += price;

chargesC = charges + priceC;

printf("\n");

}

else if (toupper(comboChoices) == 'D') {

printf("\n");

priceD = COMBO_D * quantity;

printf("       Combo D : %d * RM%.2f = RM%.2f \n", quantity, COMBO_D, priceD);

quantityD += quantity;

priceD += price;

chargesD = charges + priceD;

printf("\n");

}

printf("       Do you want to continue order ? ");

rewind(stdin);

printf("\n");

printf("       --> 1. YES. \n");

printf("       --> 2. NO.  \n");

printf("       Enter 1 or 2 to continue : ");

scanf("%d", &comboChoices);

rewind(stdin);

} while (comboChoices != 2);

total = priceA + priceB + priceC + priceD;

totalSST = total * SST;

totalPAY = total + totalSST;

totalSSTCharges = SST * total;

totalAmountCollected = total + totalSSTCharges;

totalQuantity = quantityA + quantityB + quantityC + quantityD;

printf("\n");

printf("                         <============================================================================>  \n");

printf("                         |          COMBO Charges           -->        >>  RM%5.2f <<                 |  \n", total);          

printf("                         |           Add 10%% SST            -->        >>  RM%5.2f <<                 |  \n", totalSSTCharges);

printf("                         |         Total amount PAY         -->        >>  RM%5.2f <<                 |  \n", totalPAY);

printf("                         <============================================================================>  \n");

printf("                                     Enter Amount           -->            RM");

scanf("%lf", &amountPAID);

ChangeDUE = amountPAID - totalPAY;

rewind(stdin);

printf("                         <============================================================================>  \n");

printf("                         |            Change DUE            -->         >>  RM%.2f <<                 |  \n", ChangeDUE);

printf("                         <============================================================================>  \n");

printf("\n");

printf("                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");

printf("                                        >> Thank You !! HAVE A NICE DAY !!  <<  O(^0^)O  \n");

printf("                                      vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n");

printf("\n");

printf("       Next Customer ? \n");

rewind(stdin);

printf("       --> 1. YES. \n");

printf("       --> 2. NO.  \n");

printf("       Press 1 or 2 to continue --> ");

rewind(stdin);

scanf("%c", &yesOrNo);

} while (yesOrNo != '2');

Please log in or register to answer this question.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...