/* * switchproj.c - * Project 1. * Chapter 6 * By John Stile * Purpose: Copy switch3.c to switchproj.c * Add at least 2 more menu options to the program. * Those newly added menu options should be interesting, * useful, and origina; not examined in the text book. * The formulas are possible choices. */ #include int main(void) { char cc; float mile, kilo; float pound, kilogram; float quart, leter; system("clear"); system("date"); printf("************************************\n"); printf("***Welcome to conversion world!***\n"); printf("1) Converts Miles to Kilometers.\n"); printf("2) Converts Kilometers to Miles.\n"); printf("3) Converts Pounds to Kilograms.\n"); printf("4) Converts Kilograms to Pounds\n"); printf("5) Converts Quarts to Leters\n"); printf("6) Converts Leters to Quarts\n"); printf("\n\n"); printf("Enter your menu choice: "); switch (cc=getchar()) { case '1': getchar(); printf("Enter a distance in Miles:"); scanf("%f", &mile); printf("%.1f(Mi) is %.1f(Km)\n", mile, (mile*1.6) ); break; case '2': getchar(); printf("Enter a distance in Kilometers:"); scanf("%f", &kilo); printf("%.1f(Km) is %.1f(Mi)\n", kilo, (kilo/1.6) ); break; case '3': getchar(); printf("Enter a weight in Pounds:"); scanf("%f", £); printf("%.1f(lb) is %.1f(kg)\n", pound, (pound*0.45) ); break; case '4': getchar(); printf("Enter a mass in Kilograms:"); scanf("%f", &kilogram); printf("%.1f(kg) is %.1f(lb)\n", kilogram, (kilogram/0.45) ); break; case '5': getchar(); printf("Enter a volume in Quarts:"); scanf("%f", &quart); printf("%.2f(qt) is %.2f(L)\n", quart, (quart/1.06) ); break; case '6': getchar(); printf("Enter a volume in Leters:"); scanf("%f", &leter); printf("%.2f(L) is %.2f(qt)\n", leter, (leter*1.06) ); break; default: printf("You entered an invalud choice.\n"); } printf("\n\n"); return 0; }