Okay, so here's my latest code:
Code:
#include <stdio.h>
int choice, table;
float array[10], temp, payment;
char choice2;
void tabs();
void addOrder();
void addPayment();
void printTabs();
int main(){
tabs();
printf("1) Add Order To Table's Tab.\n");
printf("2) Add Payment To Table's Tab.\n");
printf("3) Print Out All Tab Values.\n");
printf("4) Close Out All Tables and Shutdown.\n");
printf("What is your choice? ");
scanf("%i", &choice);
while (choice == 1)
addOrder();
while (choice == 2)
addPayment();
while (choice == 3)
printTabs();
if (choice == 4){
tabs();
printf("Shutting down...Goodbye!\n");
return 0;
}
while (choice < 1 || choice > 4){
printf("Invalid option.");
scanf("%i", &choice);
}
}
void tabs(){
printf("\n");
printf("Table Tabs:\n");
printf("-------------------------\n");
printf("Table #1 $%.2f\n", array[1]);
printf("Table #2 $%.2f\n", array[2]);
printf("Table #3 $%.2f\n", array[3]);
printf("Table #4 $%.2f\n", array[4]);
printf("Table #5 $%.2f\n", array[5]);
printf("Table #6 $%.2f\n", array[6]);
printf("Table #7 $%.2f\n", array[7]);
printf("Table #8 $%.2f\n", array[8]);
printf("Table #9 $%.2f\n", array[9]);
printf("Table #10 $%.2f\n", array[10]);
}
void addOrder(){
printf("C) Chili $ 2.50\n");
printf("N) Nachos $ 6.50\n");
printf("P) Pizza $ 12.00\n");
printf("S) Sliders $ 5.00\n");
printf("W) Buffalo Wings $ 10.50\n");
printf("What did the customer order?: ");
scanf("%c", &choice2);
if (choice2 == 'C' || choice2 == 'c')
temp = 2.5;
else if (choice2 == 'N' || choice2 == 'n')
temp = 6.5;
else if (choice2 == 'P' || choice2 == 'p')
temp = 12;
else if (choice2 == 'S' || choice2 == 's')
temp = 5;
else if (choice2 == 'W' || choice2 == 'w')
temp = 10.5;
while (choice2 != 'C' && choice2 != 'c' && choice2 != 'N' && choice2 != 'n' && choice2 != 'P' && choice2 != 'p' && choice2 != 'S' && choice2 != 's' && choice2 != 'W' && choice2 != 'w'){
printf("Orders have be to be one of the following:\n");
printf("C) Chili $ 2.50\n");
printf("N) Nachos $ 6.50\n");
printf("P) Pizza $ 12.00\n");
printf("S) Sliders $ 5.00\n");
printf("W) Buffalo Wings $ 10.50\n");
printf("What did the customer order?: ");
scanf("%c", &choice2);
}
printf("What table's tab are you dealing with? (Tables are numbered 1-10) ");
scanf("%i", &table);
while (table < 1 || table > 10){
printf("Tables are numbered 1-10.");
printf("Enter a valid number.");
printf("What table's tab are you dealing with? (Tables are numbered 1-10) ");
scanf("%i", &table);
}
/* Back to main() */
}
void addPayment(){
printf("What table's tab are you dealing with? (Tables are numbered 1-10) ");
scanf("%i", &table);
printf("Enter their payment amount: ");
scanf("%f", &payment);
array[table] = array[table] - payment;
/* Back to main() */
}
void printTabs(){
//int {Add local variables here!}
printf("What table's tab are you dealing with? (Tables are numbered 1-10) ");
scanf("%i", &table);
printf("Enter their payment amount: ");
scanf("%f", &payment);
while (payment > array[table]){
printf("You entered %f but their tab is only $%.2f!\n", payment, array[table]);
printf("Enter their payment amount: ");
scanf("%f", &payment);
}
/* Back to main() */
}
Here's the input:
Code:
gcc -Wall tabs.c -o tabs.out
And here's the output:
Code:
tabs.c: In function ‘main’:
tabs.c:35: warning: control reaches end of non-void function
Can anyone think of a solution?