Little help to complete my program..pls..
Code:
i ve completed my program..i can run the program and need minor changes to make it perfect..
i. i need to show the quantity chosen next to menu item output is:
enter selection :2
enter quantity 3:
current output --> Plain egg $ 2.50
it should look like this --> 3 Plain egg $2.50
2. If the selection is more than 8..if 9 is entered
output is :
Selections must be between 1 and 8
$0.00
why this $0.00 is shown here?
3. Finally, the output should look like this:
THE OUTPUT WANTED LIKE THIS :
Welcome to xxxxxx
1 orange $2.95
1 apple $3.45
2 Tea $3.60
sub total
Tax
total
CURRENT OUTPUT IS :
Welcome to xxxxxx
Enter selections :
Enter quantity :
x orange 2.95
Enter selections :
Enter quantity :
x apple 3.45
sub total
Tax
total
I NEED TO CHANGE IT TO WANTED OUTPUT...
void showMenu(menuItemType menuList[MENU_SIZE], int menuCount)
{
int index;
printf("Enter the number of your selections until you are finished, then enter -1.\n");
for(index = 0; index < menuCount; ++index)
{
printf("%d - %20s %.2f\n", index+1, menuList[index].menuItem, menuList[index].menuPrice);
}
}
void printCheck(menuItemType menuList[MENU_SIZE], int menuCount)
{
int selections = 0;
int quantity = 0;
double totalPrice = 0;
double totalTax;
printf("Welcome to xxxxxx\n");
while(selections != -1)
{
printf("Enter selection: ");
scanf("%d", &selections);
if (selections == -1)
{
break;
}
printf("Enter Quantity : ");
scanf("%d", &quantity);
if (selections >= 1 && selections <= menuCount)
{
--selections;
printf("2d %20s %.2f\n", menuList[selections].menuItem, menuList[selections].menuPrice);
totalPrice += (menuList[selections].menuPrice * quantity);
}
else
{
printf("Selections must be between 1 and %d\n", menuCount);
}
}
totalTax = (totalPrice * GST);
printf("Sub total %.2f\n", totalPrice);
printf("Tax %.2f\n", totalTax);
printf("Total %.2f\n", totalPrice + totalTax);
}