I am working on a little homework and I have to make a meal menu. In any case, my switch does not work. I try to use a simple function to pass the meaning of "fish", "drink" or "chips" and then outputs:
"Are you ordering FISH?" (or chips/drink)
I cannot make the switch work, it must determine what I pass to it, and then printf based on the code of the switch.
THE CODE:
#include <stdio.h> void menu() { printf("\nWelcome to Sunny FISH & CHIPS!\n\n"); printf("######## Fish : Haddock(K) Large(L) | $5.00\n"); printf("# FOOD # Halibut(T) Large(L) | $4.00\n"); printf("######## Chips: Cut(C) Large(L) | $2.00\n"); printf(" Ring(R) Large(L) | $3.00\n"); printf(" | \n"); printf("########## Soft Drinks(S) Large(L) | $2.00\n"); printf("# DRINKS # Coffee(C) Large(L) | $1.75\n"); printf("########## Tea(T) Large(L) | $1.50\n"); printf("---------------------------------------------\n"); printf("Note: Medium price: 80%% of large.\n"); printf(" Small price: 60%% of large.\n"); printf("TAX is 10%%.\n"); printf("More than 5 fish, 10%% discount on drink.\n"); printf("Every 10 fish purchased, get 1 free softdrink.\n"); printf(" - size of drink is according to size of fish\n"); } void question (char choice[5]) { switch (choice[5]) { case choice["fish"]: printf("Do you order FISH?\n"); case choice["drink"]: printf("Do you order CHIPS?\n"); case choice["chips"] : printf("Do you order DRINKS?\n"); default : printf("Enter a valid choice: \n"); } } main() { // menu(); question("fish"); }
source share