# Cash Register

• 01-16-2002
Hursh
Cash Register
Hi,
I need your help, I need to simulate a Cash register that enables the user to enter name of the item(s)-, then entering the number of items and price per unit (all for each item bought-maximum 20 items). This then is outputted in a table(Receipt) with items, items bought, price/unit, and line total with the subtotal and 17.5% VAT calculated to give Total payable:, finally with cash entered and change. Sorry to go on and on but I really need your help - my code so far is below can you help me with the errors?

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>

#define MAX 20

int main(void)

{
int loop,Number[20],Price[20]
char Item[20];
float Line[20];
clrscr();
for(loop=1;loop<=20;loop++)
{
printf("Please enter the name of Item %s\n",loop);
scanf("%d",&Number[loop-1]);
}
{
printf("Please input the Number of Item%s:%d\n",loop);
scanf("%d",&Number[loop-1]);
}
{
printf("Please input the Price per unit for Item%s:%d\n",loop);
scanf("%d",Price[loop-1]);
}
for(loop=1;loop<=20;loop++)
{
Line = Number*Price[loop-1];
}
subtotal = Line+%d

The end and also the middle of the code needs to be modified can you please help?
Thanx.
• 01-16-2002
Salem
> enables the user to enter name of the item
A string
> entering the number of items
an int
> and price per unit
a float

So, for 20 of each, you would have
char names[20][40]; // max 40 chars in each name
int quantity[20];
float amount[20];

Code:

```for ( i = 0 ; i < 20 ; i++ ) {   printf( "Enter name for item %d ", i+1 );   scanf( "%s", names[i] );   printf( "Enter quantity of %s ", names[i] );   scanf( "%d", &quantity[i] );   printf( "Enter unit price of %s ", names[i] );   scanf( "%f", &amount[i] ); }```
• 01-19-2002
Hursh
Thanks salem for your input-sometimes its the simple things I get wrong!! I have another querie to do with the output of say VAT(17.5%) and the subtotal-how can I add all the item prices and calculate the VAT then get the subtotal?
• 01-19-2002
Salem
C'mon, that's just some simple addition and multiplication.

At least have a go at it...
• 01-21-2002
Hursh
I will have a go but there is a particular problem, I seem to have forgotten how to output a table(like a receipt) using the inputted items as above.

I will be very grateful.
• 01-22-2002
zahid
I guess.. you don't need to entry the item name every time ..

You better create a db of items and
let them choose the item number and quantity....

That will be easy..