SHARE
TWEET

Untitled

a guest Oct 16th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3.  
  4. const float WMC_DESK = 30.5;
  5. const float WMC_BAG = 31.2;
  6. const float WMC_ROOM = 33.9;
  7. const float FLUID_DESK = 7.8;
  8. const float FLUID_BAG = 8.2;
  9. const float FLUID_ROOM = 8.35;
  10.  
  11. typedef enum {DESK, BAG, OTHERROOM} location_type;
  12.  
  13. // Function Prototypes
  14.     int printMenu ();           // prints the menu and reads the user's choice
  15.     float returnMem(int sel);          // returns the working memory capacity ranking
  16.     float returnIntel(int sel);        // returns the fluid intelligence ranking
  17.     void printRes(int sel, float working_memory, float fluid_intel);         // prints the rankings
  18.  
  19.  
  20.  
  21. int main()
  22. {
  23.     // variables
  24.     int sel;
  25.     float working_memory = 0, fluid_intel = 0;
  26.  
  27.  
  28.     //print menu, read choice
  29.     sel = printMenu();
  30.  
  31.     // Switch Case
  32.  
  33.     switch(sel)
  34.     {
  35.         case DESK:
  36.         working_memory = returnMem(sel);
  37.         fluid_intel = returnIntel(sel);
  38.         break;
  39.  
  40.         case BAG:
  41.         working_memory = returnMem(sel);
  42.         fluid_intel = returnIntel(sel);
  43.         break;
  44.  
  45.         case OTHERROOM:
  46.         working_memory = returnMem(sel);
  47.         fluid_intel = returnIntel(sel);
  48.         break;
  49.  
  50.         default:
  51.             working_memory = 0;
  52.             fluid_intel = 0;
  53.  
  54.     // add exit/default?
  55.  
  56.     }
  57.  
  58.  
  59.  
  60.     printRes(sel, working_memory, fluid_intel);
  61.  
  62.     return 0;
  63.  
  64.  
  65. }
  66.  
  67. int printMenu()         // prints the menu and reads user's choice
  68. {
  69.     int sel;
  70.     printf("Cell Phone Locations\n\n");
  71.     printf("1. Desk\n");
  72.     printf("2. Pocket/Bag\n");
  73.     printf("3. Other Room\n\n\n");
  74.  
  75.     // read the user's choice
  76.  
  77.     printf("Enter your selection: ");
  78.     scanf("%d", &sel);
  79.  
  80.     sel = sel - 1;
  81.  
  82.     return sel;
  83. }
  84.  
  85.  
  86. float returnMem(int sel)
  87. {
  88.     float working_memory;
  89.  
  90.  
  91.     switch(sel)
  92.    {
  93.     case DESK:
  94.         working_memory = 30.5;
  95.         break;
  96.  
  97.     case BAG:
  98.         working_memory = 31.2;
  99.         break;
  100.  
  101.     case OTHERROOM:
  102.         working_memory = 33.9;
  103.         break;
  104.  
  105.     default:
  106.         working_memory = 0;
  107.  
  108.    }
  109.  
  110.  
  111.     return working_memory;
  112. }
  113.  
  114. float returnIntel(int sel)
  115. {
  116.     float fluid_intel;
  117.  
  118.     switch(sel)
  119.     {
  120.     case DESK:
  121.         fluid_intel = 7.8;
  122.     break;
  123.  
  124.     case BAG:
  125.         fluid_intel = 8.2;
  126.         break;
  127.  
  128.     case OTHERROOM:
  129.         fluid_intel = 8.35;
  130.         break;
  131.  
  132.     default:
  133.         fluid_intel = 0;
  134.  
  135.     }
  136.  
  137.     return fluid_intel;
  138. }
  139.  
  140.  
  141. void printRes(int sel, float working_memory, float fluid_intel)
  142. {
  143.  
  144.  
  145.  
  146.  
  147.     printf("Your OSpan Score is %4.2f out of 35\n", working_memory);
  148.     printf("Your Fluid Intelligence ranking is %4.2f out of 10\n", fluid_intel);
  149.  
  150.     return;
  151.     //print location too
  152. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top