/* convert7.c This program converts integers given by the user from the English unit of measure, inches, to the form of their choice. A switch statement is used to offer the user a choice as to which conversion they would like to make. This program may not reflect all the requirements of the C Coding Standards used in this class. */ #include <stdio.h> int main() { int inches, choice; float meters; printf("This program will convert inches into the Metric System.\n"); printf("Please enter an integer: "); scanf("%d", &inches); /* Notice how much you can format ouput with printf. */ printf("Choose unit to convert %d inches into:\n\n", inches); printf("\t1. feet\n\t2. yards\n\t3. centimeters\n"); printf("\t4. meters\n\t5. kilometers\n\n"); printf("Enter a number 1 - 5: "); scanf("%d", &choice); printf("%d inches converts to ", inches); switch(choice) { case(1): printf("%.1f feet.\n", inches / 12.0); break; case(2): printf("%.1f yards.\n", inches / 36.0); break; case(3): printf("%.1f centimeters.\n", inches * 2.54); break; case(4): printf("%.1f meters.\n", inches * .0254); break; case(5): printf("%.1f kilometers.\n", inches * .0000254); break; default: printf("%d inches since a valid choice was not made.\n", inches); break; } return(0); }