hi pls gelp me with my assignment.. i supposed to create a cash register program that will calculate customer's payment and change..
here's what i have so far..


int main(void)

printf("Welcome to Reddish Bar&Cafe");
printf("\n\n\Choose from the items below:");

printf("\n\n\n\Margarita= 25 bucks");
printf("\n\Beer= 10 bucks");
printf("\n\Martini= 35 bucks");
printf("\n\Rhum= 20 bucks");
printf("\n\Tequilla= 25 bucks");
printf("\n\Shots= 10 bucks");

int a, answer, yes;
    printf("\n\n\ enter first item;");

    printf("do you want to add another another item?");
        printf(" yes or no? ");
        printf("\n\n\please enter another item");
printf("\n\n\n\Thank you and come back again!!");

return 0;

i cannot push thru.. i dont know to calculate as well. please help

1) check that the customer has given you an amount exceeding his bill

2) use this equation: amount given - bill equals change due back to the customer

imo the easy way to deal with money is to multiply it all by 100, in order to eliminate any amount less than one (pennies are now dollars). Then do all the math making your change, (a while (change > 0) loop with every denomination of change inside it, is perhaps easiest to understand), and finally, print out the final bills, and use %.2d to print the coins (which you will have added up and know that they are less than 100 in value).

There is a sweet math way to do this, but it's harder to figure out.

Work on that, and post up your revised code. USE CODE TAGS AROUND YOUR PROGRAM CODE (highlight your code and click on the [code] icon in the editor window).

People won't study code that is all smashed up like html text.

thanks.. il try to work on this, this is pretty hard and making me really sleepless.. pls correct my codes once im done.. thanks!!!

You're welcome, and I will. The first thing is to stop and think how YOU would make change - step by step - what is that process?

That's your pseudo code (logic outline), for the program.

I would prefer to you to make it on C++ or C# !!!!

Right! We'll just need 4 instantiations of the coin class, and 4 more of the class dollar_bill. Then we'll need an inherited object of these two classes, for the bill and the change due.

You'd have to decide what will be private data, and what will be public data, for each of the above, and their relative worth assigned.

Then, at last, you'll get down to doing the very same arithmetic that you'd do in a procedural language! ;)

OOP is good for a lot of things, but it has no easy answers in this case.

hi.. i revised it but its still not running properly.. can you check it?


#define Margarita 25
#define Beer 10
#define Martini 35
#define Rhum 20
#define Tequilla 25
#define Shots 10

void main(void)

     int a=0, b=0, c=0, d=0, e=0, f=0, p=0;
     float amount_a=0, amount_b=0, amount_c=0, amount_d=0, amount_e=0, amount_f=0, amount=0, payment=0,change=0;
     char x, z;

printf("\nWelcome to Reddish Bar&Cafe");
printf("\n\n\Choose the  letter of your choice:");

printf("\n\a.   Margarita= 25 bucks");
printf("\n\b.   Beer= 10 bucks");
printf("\n\c.   Martini= 35 bucks");
printf("\n\d.   Rhum= 20 bucks");
printf("\n\e.   Tequilla= 25 bucks");
printf("\n\f.   Shots= 10 bucks");

    printf("\n\n\ Your order please?..");
    printf("\n\nYou ordered %c",&x);
    printf("\n\n\ How many bottles do you want to buy?:");
    printf("\n\n\ Do you have another order?..[y/n]");

if (x=='a'||x=='A')

else if (x=='b'||x=='B')

else if (x=='c'||x=='C')

else if (x=='d'||x=='D')

else if (x=='e'||x=='E')

else if (x=='f'||x=='F')

/*getch(); */



printf("\n\n\ Your bill is as follows:");

if (amount_a>0)
   printf("\n\n\ %d bottles of Margarita is %f", &a, &amount_a);

else if (amount_b>0)
     printf("\n\n\ %d bottles of Beer is %f", &b, &amount_b);

else if (amount_c>0)
     printf("\n\n\ %d bottles of Martini is %f", &c, &amount_c);

else if (amount_d>0)
     printf("\n\n\ %d bottles of Rhum is %f", &d, &amount_d);

else if (amount_e>0)
     printf("\n\n\ %d bottles of Rhum is %f", &e, &amount_e);

else if (amount_f>0)
     printf("\n\n\ %d bottles of Shots is %f", &f, &amount_f);



printf("\n\n\your total bill is %f", &amount);

printf("\n\n\You gave %f", &payment);


printf("\n\n\your change is %f", &change);