/* File: menu.c
An example of a menu driven program. The main() driver prints the menu,
reads the selected item, and performs an appropriate task. */
#include <stdio.h>
#include "payroll.h"
main()
{ signed char c;
int id;
float hours_worked, rate_of_pay, pay;
printf("***Pay Calculation: Menu Driven***\n\n"); /* print title */
print_menu(); /* Display the menu to the user */
while ((c = getchar()) != EOF) { /* get user selection */
switch(c) { /* select an appropriate path */
case 'g': /* should be a function get_data() */
case 'G': printf("Id number: ");
scanf("%d", &id);
printf("Type Hours worked and rate of pay\n");
scanf("%f %f", &hours_worked, &rate_of_pay);
break;
case 'd':
case 'D': display_data(id, hours_worked, rate_of_pay);
break;
case 'm':
case 'M': modify_data();
break;
case 'c':
case 'C': pay = calc_pay(hours_worked, rate_of_pay);
break;
case 'p':
case 'P': display_data(id, hours_worked, rate_of_pay);
print_pay(pay);
break;
case 'h':
case 'H': print_menu();
break;
case 'q':
case 'Q': exit(0);
default: printf("Invalid selection\n");
print_menu();
} /* end of switch */
while ((c = getchar()) != '\n'); /* flush the buffer */
} /* end of while loop */
} /* end of program */