[Previous Homework] [Next Homework]

hw09 - Menus with While Loops


From Linux on the GL machine:
  • Write a C program (see below) and save it in a file called menu1.c in your ./cmsc104/hw09 directory

  • Compile the program:
    gcc -lm -o menu1 menu1.c

  • Run the program to make sure it works:
    ./menu1

  • Use the SUBMIT utility turn in the homework.
    submit cs104_grasso hw09 menu1.c menu1


Create a program that displays a menu of conversion functions available to a user. Execute whatever conversions the users chooses until they choose the option to quit the program.

  • Add #include <math.h> at the top of your source file

  • Display a menu to the user that looks like the following:
    
    Choose one option:
    	1 - Convert Fahrenheit to Celsius
    	2 - Convert kilometers to miles
    	3 - Convert fathoms to feet
    	4 - Convert meters to yards
    	5 - Convert decimal to binary
    	0 - Exit program
    

  • Read in the option number from the keyboard
  • Echo the option back to the user
  • Verify that the option is valid. If not, show the user an appropriate error message and re-display the menu.
  • Based on the valid input value, call the appropriate conversion function.
  • Redisplay the menu and perform the function until the user inputs 0 to exit the program.


Make sure that you follow all the coding standards