program point of sale

,,,hi 2 evry one,im a knew member of this forum i just
needed anyones help in our project 2 b pass 1 week from now,,
our prof want us to make a simple program about a point of sale
anybody help me pls.thanks in advance
So he wants you to make a cash register correct? if thats not it then ignore all of this but i would assume since its just a big calculator and to head that direction. along with some other statements to break it up that way when each item is registered, or "scanned" if you will, it will continue to build up until whoever is using it presses or types total then at that point sum everything up. those are some ideas i suppose, it makes me want to try and write something up for it tho. lol
thank you 4 ur sugestion,,i hav already made a program of point of sale of a Burger House Business,but stil,i need help bcoz i know it has errors..
here is the example output of my program..

BURGER HOUSE MENU

(a)footlong----------25
(b)burger------------20
(c)cheese burger--25
(d)frenc fries--------15

DRINKS
(e)orange juice----15
(f)coke in can-------20
(g)mineral water--15
(h)iced tea----------15

Enter the letter of order:
a d f
Your order are:
(a)footlong------25
(d)french fries--15
(f)coke in can---20

total = 60
cash = 100
change=40

TRANSACTION COMPLETE!!!!
(this should b the flow of my program,help me pls.thanks in advance again)
Could you supply the code please?
hir's d code,,

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define PHRASE"TRANSACTION COMPLETE!!!!"
void main()
{
char ord[50];
int a,b,c,d,e,f,g,h,l;
int cash; int total; int change;
a=25; b=20; c=25; d=15; e=15;f=20;g=15; h=15;
clrscr();
gotoxy(6,2)prinf("BURGER HOUSE MENU");
printf("\n\n(a)footlong-----25");
printf("\n(b)Burger---------20");
printf("\n(c)cheese burger-25");
printf("\n(d)french fries-----15");
printf("\n\nDRINKS");
printf("\n(e)orange juice");
printf("\n(f)coke in can");
printf("\n(g)mineral water");
printf("\n(h)iced tea");
printf("\n\nEnter the letter of your order:");
gets(order);
for(l=o;l<order;l++);
switch(order[l]){
case'a':printf("\n(a)footlong-----25");break;
case'b':printf("\n(b)burger-------20");break;
case'c':printf("\n(c)cheese burger--25");break;
case'd':printf("\n(d)french fries---15");break;
case'e':printf("\n(e)orange juice--15");break;
case'f':printf("\n(f)coke in can --20");break;
case'g':printf("\n(g)mineral water----15");break;
case'i':printf("\niced tea-----15");break;
}
total=l+l;
printf("\ntotal=%d",total);
printf("\nCash:");
scanf("%d",&l);
change=cash-total;
printf("\nChange=%d",change);
printf("\n\n%s",PHRASE);
getch();
}
Last edited on
What's the error?
There is an extraneous semicolon on the for loop, so the loop does nothing.
Also I think you need some braces around the for loop.
And the line total=l+l, needs to be inside the loop (and it is also wrong).
thats why im asking for help
Ok. Let me format your code and add comments as to what it does and maybe that will help. I'm going to remove a lot of the prints to shorten it up a bit:

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
void main()           // This should be int main()
{
    char ord[50];
    int a,b,c,d,e,f,g,h,l;
    int cash; int total; int change;

    a=25; b=20; c=25; d=15; e=15;f=20;g=15; h=15;

    // Clear screen, draw menu.
    // etc... code removed for brevity

    // Read in the number of items the user wants to order
    gets(order);         // Read in as a STRING, not an INTEGER

    // Assume you meant '0' and not 'o', as the code would not compile with 'o'.
    // Since order is of type char[], order is a pointer.  This makes 'l' count from
    // zero to the value of the pointer.
    for(l=o;l<order;l++);   // <- Semicolon here ends the for loop (so body does nothing).

    // Access the l'th byte of the order array.  Since 'l' counted from 0 to the address
    // of the order array, l is huge, and this will access well beyond the array bound
    // and most certainly crash.
    switch( order[l] )
    {
         // Cases omitted for brevity.
    }

    // Set total equal to twice the value of 'l', which is again the address of 'order'.
    total=l+l;

    // Output total cost and ask for payment amount.
    printf("\ntotal=%d",total);
    printf("\nCash:");
    scanf("%d",&l);        // Read the payment amount into 'l'

    // The change is equal to the amount of the payment minus the total cost.
    // The amount of the payment was read into 'l', but here we use 'cash' as
    // the payment amount.  Also, per above comments, total is not the total
    // cost, it is 2 * address of 'order'. 
    change=cash-total;

    // Output the change amount, etc.
    printf("\nChange=%d",change);
    printf("\n\n%s",PHRASE);

    // Pause terminal so window isn't closed immediately
    getch();
}

my program are running good but there is still last one error,the total are not responding,,what should be the code for it,,thanks again in advance,im hoping for your correct suggestion,,,,
please help me,im running out of time,this project is to be pass on thursday,so pls. help me...thanks
Please post your new code and explain what you mean by "the total are not responding".
there is no changes in my code,the code "total=l+l",is not responing to what it should calculate,if i order "a" my order is footlong-25,after that instead of total 25,my total is equals to 1. do you know the code for it,help me again please,thanks again.
Last edited on
You have many bugs that I (indirectly) pointed out above prior to that line of code.
You need to fix those bugs first.

Line 13 is wrong. Line 18 is wrong. Line 23 is wrong. Fix those and then repost
your code.
hirs my code,only the calculation "total=l+l" are not working,


#include<stdio.h>
#include<conio.h>
#include<string.h>
#define PHRASE"TRANSACTION COMPLETE!!!!"
int main()
{
char ord[50];
int a,b,c,d,e,f,g,h,l;
int cash; int total; int change;
a=25; b=20; c=25; d=15; e=15;f=20;g=15; h=15;
clrscr();
gotoxy(6,2)prinf("BURGER HOUSE MENU");
printf("\n\n(a)footlong-----25");
printf("\n(b)Burger---------20");
printf("\n(c)cheese burger-25");
printf("\n(d)french fries-----15");
printf("\n\nDRINKS");
printf("\n(e)orange juice");
printf("\n(f)coke in can");
printf("\n(g)mineral water");
printf("\n(h)iced tea");
printf("\n\nEnter the letter of your order:");
gets(order);
for(l=0;l<order;l++)
switch(order[l]){
case'a':printf("\n(a)footlong-----25");break;
case'b':printf("\n(b)burger-------20");break;
case'c':printf("\n(c)cheese burger--25");break;
case'd':printf("\n(d)french fries---15");break;
case'e':printf("\n(e)orange juice--15");break;
case'f':printf("\n(f)coke in can --20");break;
case'g':printf("\n(g)mineral water----15");break;
case'i':printf("\niced tea-----15");break;
}
total=l+l;
printf("\ntotal=%d",total);
printf("\nCash:");
scanf("%d",&l);
change=cash-total;
printf("\nChange=%d",change);
printf("\n\n%s",PHRASE);
getch();
}
Ok, your computer knows how to add l to itself and assign the result to total. If total isn't the right number, then l isn't the right number. And I can tell you that l is not correct because of the bugs I pointed out.
Topic archived. No new replies allowed.