/* menu.c, Dianna Xu

  Unit conversion between mile and km with menu

*/

#include <stdio.h>

int main() {

  int choice;
  double mile, km;

  printf(
	  "=== Conversion between mile and km ===\n"
	  "1. To convert mile to km\n"
	  "2. To convert km to mile\n"
	  "Enter the number corresponding to the desired operation: ");

  scanf("%d", &choice);
  
  if (choice == 1) {
    printf("Enter a mile value: ");
    scanf("%lf", &mile);
    km = mile * 1.6;
    printf("%f mile(s) = %f km\n", mile, km);
  }

  else if (choice == 2) {
    printf("Enter a km value: ");
    scanf("%lf", &km);
    mile = km / 1.6;
    printf("%f km = %f mile(s)\n", km, mile);
  }
  
  /* for all other integers */
  else  
    printf("\n*** error: invalid choice ***\n");

  return 0;
}
