#include #include "myio_c.h" #include "arraylib.h" #define DAYS 31 #define DATA_IN 1 #define HIGH 2 #define LOW 3 #define HIGH_DAY 4 #define LOW_DAY 5 #define AVERAGE 6 #define TOTAL 7 #define NUM_DAYS 8 #define DATA_OUT 9 #define QUIT 10 void print_menu(void); void print_dollar(int); void main(void) { int spending[DAYS], choice = 10, actual = -1; int stop_val = -1; int high, low, high_day, low_day, total, num_days; float average; do { print_menu(); get_int_bound(&choice, 1, 10); switch(choice) { case DATA_IN: fill_1d_part(spending, actual + 1, DAYS - 1, &actual, stop_val); break; case HIGH: if (actual == -1) printf("\nMust enter data first "); else printf("\nnot yet implemented"); break; case LOW: if (actual == -1) printf("\nMust enter data first "); else printf("\nnot yet implemented"); break; case HIGH_DAY: if (actual == -1) printf("\nMust enter data first "); else printf("\nnot yet implemented"); break; case LOW_DAY: if (actual == -1) printf("\nMust enter data first "); else printf("\nnot yet implemented"); break; case AVERAGE: if (actual == -1) printf("\nMust enter data first "); else printf("\nnot yet implemented"); break; case TOTAL: if (actual == -1) printf("\nNo data entered - total = 0"); else { total = sum_1d(spending, 0, actual); printf("\nTotal = %d", total); } break; case NUM_DAYS: printf("\nNumber of days = %d", actual + 1); case DATA_OUT: if (actual == -1) printf("\nMust enter data first "); else printf("\nnot yet implemented"); break; case QUIT: printf("\nQuitting program \n\n"); } } while (choice != QUIT); } void print_menu(void) { printf("\n\nMenu Options"); printf("\n1: Input data "); printf("\n2: High value "); printf("\n3: Low value "); printf("\n4: High day "); printf("\n5: Low day "); printf("\n6: Average spent "); printf("\n7: Total spent"); printf("\n8: Number of days"); printf("\n9: Output data "); printf("\n10: Quit\n\n"); } void print_dollar(int amount) { float temp = amount/100.0; printf("$%8.2f", temp); }