daisypolly
Programmer
Hi,
I am making a cash register in C. I want to have an add ,remove functionality.I am doing that I get an error.
The user will press 1 and they will be able to add the item name and the item price.
my code is:
<code>
#include <stdio.h>
int itemPrice = 0;
char itemName ;
int main(int argc, char *argv[]){
int n = 0;
int number=0;
int price1=0;
char item1;
while ( number <= 6 ) {
printf("1. Add Item\n");
printf("2. Compute Total\n");
printf("3. Compute Average\n");
printf("4. Compute Change\n");
printf("5. Reset Cash-register\n");
printf("6. Quit\n");
printf("Enter Option: ");
scanf("%d",&number);
if(number==1){
scanf("%d,%c",price1,item1);
add(price1,item1);
//printf("basket is %d",price1,item1);
}
if(number==3){
printf("you pressed3\n");
}
if(number==4){
printf("you pressed4\n");
}
if(number==5){
printf("you pressed5\n");
}
if(number==6){
break;
}
if(number>6){
printf("Invalid Option\n");
}
break;
}
}
void add(int aPrice,char aName){
itemPrice = aPrice;
itemName = aName;
}
</code>
Thanks for anyone who can help.
Daisy
I am making a cash register in C. I want to have an add ,remove functionality.I am doing that I get an error.
The user will press 1 and they will be able to add the item name and the item price.
my code is:
<code>
#include <stdio.h>
int itemPrice = 0;
char itemName ;
int main(int argc, char *argv[]){
int n = 0;
int number=0;
int price1=0;
char item1;
while ( number <= 6 ) {
printf("1. Add Item\n");
printf("2. Compute Total\n");
printf("3. Compute Average\n");
printf("4. Compute Change\n");
printf("5. Reset Cash-register\n");
printf("6. Quit\n");
printf("Enter Option: ");
scanf("%d",&number);
if(number==1){
scanf("%d,%c",price1,item1);
add(price1,item1);
//printf("basket is %d",price1,item1);
}
if(number==3){
printf("you pressed3\n");
}
if(number==4){
printf("you pressed4\n");
}
if(number==5){
printf("you pressed5\n");
}
if(number==6){
break;
}
if(number>6){
printf("Invalid Option\n");
}
break;
}
}
void add(int aPrice,char aName){
itemPrice = aPrice;
itemName = aName;
}
</code>
Thanks for anyone who can help.
Daisy