/* ----------------------------------------------------------------------------- // Pencil and Paper Exercise 14.5. // ----------------------------------------------------------------------------- */ #include "tools.h" typedef enum STATE { AWFUL, BAD, OK, GOOD, FINE } state_t; typedef struct JUNK { char name[16]; short size; float price; state_t status; } junk_t; /* ----------------------------------------------------------------------------- */ void main( void ) { string label[] = { "Awful", "Bad", "Ok", "Good", "Fine" }; junk_t j[3] = { {"rug",0,0}, {"chair",0,0}, {"table",0,0} }; int k; banner(); for(k=0; k<3; ++k) { printf( "\n Next item: %s ", j[k].name ); j[k].status = menu_i( " Condition of object: ", 5, label ); printf( " Price of item: " ); scanf( "%g", &j[k].price ); } puts( "\n Inventory:\n" ); for(k=0; k<3; ++k) { printf( "\t%-18s%-6s%7.2f\n", j[k].name, label[ j[k].status ], j[k].price ); } bye(); }