Advertisement
TukoVPN

secondTermExam

Nov 30th, 2021
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<conio.h>
  4.  
  5. void mainMenu();
  6. void feetMile();
  7. void mileFeet();
  8. void inchFoot();
  9. void footInch();
  10. void celFah();
  11. void fahCel();
  12.  
  13. void feetMile(){
  14. system("cls");
  15. float feet, mile;
  16. printf("\n\t\tENTER FEET: ");
  17. scanf("%f", &feet);
  18.  
  19. //COMPUTATION
  20. mile = feet / 5820;
  21.  
  22. printf("\n\t\t%f FEET is equal to %f MILE", feet, mile);
  23. printf("\n\t\tPress any key to go back to Main Menu...");
  24. getch();
  25. mainMenu();
  26. }
  27. void mileFeet(){
  28. system("cls");
  29. float feet, mile;
  30. printf("\n\t\tENTER MILE: ");
  31. scanf("%f", &mile);
  32.  
  33. //COMPUTATION
  34. feet = mile * 5820;
  35.  
  36. printf("\n\t\t%f MILE is equal to %f FEET", mile, feet);
  37. printf("\n\t\tPress any key to go back to Main Menu...");
  38. getch();
  39. mainMenu();
  40. }
  41. void inchFoot(){
  42. system("cls");
  43. float inch, foot;
  44. printf("\n\t\tENTER INCH: ");
  45. scanf("%f", &inch);
  46.  
  47. //COMPUTATION
  48. foot = inch / 12;
  49.  
  50. printf("\n\t\t%f INCH is equal to %f FOOT", inch, foot);
  51. printf("\n\t\tPress any key to go back to Main Menu...");
  52. getch();
  53. mainMenu();
  54. }
  55. void footInch(){
  56. system("cls");
  57. float inch, foot;
  58. printf("\n\t\tENTER FOOT: ");
  59. scanf("%f", &foot);
  60.  
  61. //COMPUTATION
  62. inch = foot * 12;
  63.  
  64. printf("\n\t\t%f FOOT is equal to %f INCH", foot, inch);
  65. printf("\n\t\tPress any key to go back to Main Menu...");
  66. getch();
  67. mainMenu();
  68. }
  69. void celFah(){
  70. system("cls");
  71. float cel, fah;
  72. printf("\n\t\tENTER CELSIUS: ");
  73. scanf("%f", &cel);
  74.  
  75. //COMPUTATION
  76. fah = (cel * 1.8) + 32;
  77.  
  78. printf("\n\t\t%f CELSIUS is equal to %f FAHRENHEIT", cel, fah);
  79. printf("\n\t\tPress any key to go back to Main Menu...");
  80. getch();
  81. mainMenu();
  82. }
  83. void fahCel(){
  84. system("cls");
  85. float cel, fah;
  86. printf("\n\t\tENTER FAHRENHEIT: ");
  87. scanf("%f", &fah);
  88.  
  89. //COMPUTATION
  90. cel = (fah - 32) * .5556;
  91.  
  92. printf("\n\t\t%f FAHRENHEIT is equal to %f CELSIUS", fah, cel);
  93. printf("\n\t\tPress any key to go back to Main Menu...");
  94. getch();
  95. mainMenu();
  96. }
  97. void mainMenu(){
  98. int choice;
  99.  
  100. printf("\n\t\t************************************************");
  101. printf("\n\t\t INPUT, OUTPUT, AND MATH EXPRESSION STRUCTURES");
  102. printf("\n\t\t************************************************");
  103. printf("\n\n\t\t[1]. FEET TO MILE");
  104. printf("\n\t\t[2]. MILE TO FEET");
  105. printf("\n\t\t[3]. INCH TO FOOT");
  106. printf("\n\t\t[4]. FOOT TO INCH");
  107. printf("\n\t\t[5]. CELSIUS TO FAHRENHEIT");
  108. printf("\n\t\t[6]. FAHRENHEIT TO CELSIUS");
  109. printf("\n\t\t[7]. EXIT");
  110.  
  111. printf("\n\n\t\tENTER CHOICE: ");
  112. scanf("%d", &choice);
  113.  
  114. switch(choice){
  115. case 1:
  116. feetMile();
  117. break;
  118. case 2:
  119. mileFeet();
  120. break;
  121. case 3:
  122. inchFoot();
  123. break;
  124. case 4:
  125. footInch();
  126. break;
  127. case 5:
  128. celFah();
  129. break;
  130. case 6:
  131. fahCel();
  132. break;
  133. case 7:
  134. exit(1);
  135. break;
  136. default:
  137. printf("\n\t\tINVALID CHOICE!");
  138. exit(1);
  139. }
  140.  
  141. }
  142. int main(){
  143. mainMenu();
  144. return 0;
  145. }
  146.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement