<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3. enter 2 numbers pidgey,candies
  4.  
  5. evolutions is equal to no. of candies divided by 12
  6. absolute evolutions is equal to evolutions plus evolutions divided by 12
  7. total XP is equal to 500 multiplied by 2 multiplied by absolute evolutions
  8.  
  9. IF pidgey value is less than the absevo value
  10.    THEN
  11.       absolute evolutions is equal to pidgey value
  12.       total XP is equal to 500 multiplied by 2 multiplied by absolute evolutions
  13. END IF
  14.  
  15. IF pidgey value is greater than the absevo value
  16.    THEN
  17.       absolute evolutions is equal to evolutions plus evolutions divided by 12
  18.       total XP is equal to 500 multiplied by 2 multiplied by absolute evolutions
  19. END IF
  20.  
  21. IF pidgey value is equal to 0
  22.    THEN
  23.       display error message
  24. END IF
  25.  
  26. IF candies value is equal to 0
  27.    THEN
  28.       display error message
  29. END IF
  30. IF pidgey value is less than 0
  31.    THEN
  32.       absolute evolutions becomes 0
  33.       pidgey becomes 0
  34.       total XP becomes 0
  35.       display error message
  36. END IF
  37.  
  38. IF candies value is less than 0
  39.    THEN
  40.       absevo becomes 0
  41.       total XP becomes 0
  42.       display error message
  43. END IF
  44.  
  45. IF candies value is less then 12
  46.    THEN
  47.       display message
  48. END IF
  49.  
  50. IF pidgey values is not a whole number
  51.    THEN
  52.       absevo becomes 0
  53.       pidgey becomes 0
  54.       totalXP becomes 0
  55.       display error message
  56. END IF
  57.  
  58. IF candie values is not a whole number
  59.    THEN
  60.       absevo becomes 0
  61.       totalXP becomes 0
  62.       display error message
  63. END IF
  64.  
  65. diplay total XP value
  66. END
  67. */
  68. #include <stdio.h>
  69.  
  70. int main (void)
  71. {
  72.    float pidgey = 0 , candies = 0; //variable inputs
  73.    /*constants*/
  74.    int evolutionXP = 500;
  75.    int luckyeggbonus = 2;
  76.    int evolutions, absevo, totalXP;//resultant variables
  77.    
  78.    
  79.    scanf("%f %f", &pidgey, &candies ); //allows user to input values for pidgeys and candies
  80.    
  81.    /*No. of evolutions calculations*/
  82.    evolutions = (candies/12); //calculates evolutions by diiding candies by 12
  83.    absevo = (evolutions + (evolutions/12));
  84.    totalXP = (evolutionXP*absevo*luckyeggbonus);//equation for totalXP
  85.    
  86.    {
  87.    if  (pidgey < absevo) //prevents the program from calculating more evolutions than pidgeys
  88.    { 
  89.       absevo = (pidgey);
  90.       totalXP = (evolutionXP*absevo*luckyeggbonus);
  91.    }}
  92.  
  93.    {
  94.    if (pidgey > absevo) //prevents the program calculating more pidgeys than evolutions
  95.    {
  96.       absevo = (evolutions + (evolutions/12));
  97.       totalXP = (evolutionXP*absevo*luckyeggbonus);
  98.    }}
  99.    
  100.    
  101.    /*Errors*/
  102.    if (pidgey == 0) //if pidgeys are equal to 0, display error message
  103.    {
  104.    fprintf(stderr, "no: input value missing/incorrect.  Please enter the number of pidgeys.\n");
  105.    }
  106.    
  107.    if (candies == 0) //if candies are equal to 0, display error message
  108.    {
  109.    fprintf(stderr, "ERROR: input value missing/incorrect.  Please enter the number of candies.\n");
  110.    }
  111.    
  112.    if (pidgey < 0) //if negative values are entered for pidgeys, display error message
  113.    {
  114.       absevo = 0;
  115.       pidgey = 0;
  116.       totalXP = 0;//stops negative value inputs from giving an unwanted output
  117.    fprintf(stderr, "ERROR: input value incorrect.  Can not have negative number of pidgeys.\n");
  118.    }
  119.      
  120.    if (candies < 0) //if negative values are entered for candies, display error message
  121.    {
  122.       absevo = 0;
  123.       totalXP = 0;
  124.    fprintf(stderr, "ERROR: input value incorrect.  can not have negative number of candies.\n");
  125.    }
  126.    
  127.    if (candies < 12) //if values less than 12 are entered for candies, display message
  128.    {
  129.    printf( "(!) Insuffiecient candies for an evolution. No experience gained (!)\n");
  130.    }
  131.    
  132.    if (fmod ((pidgey*10),10) !=0) //if pidgey value is a decimal number, diplay message
  133.    {
  134.       absevo = 0;
  135.       pidgey = 0;
  136.       totalXP = 0;//stops negative value inputs from giving an unwanted output
  137.    fprintf(stderr,"ERROR: input value incorrect.  pidgey input value must be an interger.\n");
  138.    }
  139.    
  140.    if (fmod ((candies*10),10) !=0)//if candies value is a decimal number, display message
  141.    {
  142.       absevo = 0;
  143.       totalXP = 0;//stops negative value inputs from giving an unwanted output
  144.    fprintf(stderr,"ERROR: input value incorrect.  candie input value must be an interger.\n");
  145.    }
  146.    
  147.    /*Display*/
  148.    printf("Max XP the player can earn  is %d", totalXP); // displays Max XP
  149.    }