View Poll Results: Can you help??

Voters
2. You may not vote on this poll
  • Do you agree?

    0 0%
  • Do you disagree?

    2 100.00%

Cash Register

This is a discussion on Cash Register within the C Programming forums, part of the General Programming Boards category; Hi, I need your help, I need to simulate a Cash register that enables the user to enter name of ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    6

    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.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,589
    > 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] );
    }

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    6
    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?

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,589
    C'mon, that's just some simple addition and multiplication.

    At least have a go at it...

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    6
    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.

  6. #6
    Registered User zahid's Avatar
    Join Date
    Aug 2001
    Posts
    532
    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..
    [ Never code before desk work ]
    -------------------------------------:-->
    A man who fears Nothing is the man who Loves Nothing
    If you Love Nothing, what joy is there in your life.
    =------------------------------------------------------= - I may be wrong.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help it won't compile!!!!!
    By esbo in forum C Programming
    Replies: 58
    Last Post: 01-04-2009, 02:22 PM
  2. Help fixing my cash register program.
    By lil_rom in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2008, 02:28 PM
  3. Cash register program help :(
    By lil_rom in forum C Programming
    Replies: 2
    Last Post: 04-11-2008, 12:35 AM
  4. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  5. ascii rpg help
    By aaron11193 in forum C Programming
    Replies: 18
    Last Post: 10-29-2006, 01:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21