<mosaic.cnfolio.com>
PROGRAM
  1. /*Pseudo code
  2. START
  3.  
  4.    Start with zero pidgeys, zero candys and zero evolutions.
  5.    Read the first number entered this is the amount of pidgeys.
  6.    Read the second number entered this is the amount of candys.
  7.    
  8.       IF the number of pidgeys entered is greater than zero and the number of candy entered is greater than 12 begin the program.
  9.          if the numbers entered for pidgeys or candys are incorrect the program will not run and create an error message.
  10.          
  11.          While the number of candy is greater than pidgey subtract 12 candy, add one candy back.
  12.                increase the number of evolutions by one
  13.          End while
  14.          
  15.       When the amount of pidgeys left reaches zero the program will stop and display results.   
  16.       Display the number of evolutions and the amount of xp gained.
  17.      
  18.       If the number of pidgeys entered is less than 1
  19.      
  20.       THEN display an error message to input a value greater than zero
  21.      
  22.       End if
  23.      
  24.       If the number of candy is less than 12
  25.      
  26.       THEN display an error message that there is not enough candy
  27.      
  28.       End if
  29.      
  30.       If a decimal value is entered for pidgey
  31.      
  32.       THEN display an error message to enter a whole number greater than zero
  33.      
  34.       End if
  35.      
  36.       If a decimal value is entered for candy
  37.      
  38.       THEN display an error message to enter a whole number greater than 12
  39. END
  40. */
  41. #include <stdio.h>
  42. #include <math.h>
  43. int main ( void )
  44.  
  45. {
  46.  
  47.    float pidgey=0;/* float is used rather than int to be able to read decimal values*/
  48.    float candy=0; /* float is used rather than int to be able to read decimal values*/
  49.    int evolutions=0;
  50.    
  51.    scanf( "%f %f" , &pidgey, &candy );
  52.    if ((floor(pidgey)==pidgey) && (floor(candy)==candy) && (pidgey>0) && (candy>12)) /*floor is used to round down inputs and make them equal to the inputs we want. This allows us to generate an error if a decimal number is entered.*/
  53.    {
  54.    
  55.    while (candy>=12 && pidgey>0 )/*while loop conditions are set*/
  56.       {
  57.       candy=candy-12;/*subtract 12 candys required for 1 evolution*/
  58.       candy++;       /*return the 1 bonus candy gained for an evolution*/
  59.       evolutions++;  /*increments the number of evolutions starting from zero*/
  60.       pidgey--;      /*decrements the number of pidgey entered, when it reaches zero it breaks while loop conditions and exits*/
  61.        
  62.       }
  63.       printf("pidgey evolutions = %d", evolutions);
  64.       printf(" \n total xp = %d", evolutions*1000);
  65.      
  66.    }
  67.    
  68.    else
  69.    {
  70.    if(pidgey<1)
  71.       {
  72.         printf("\n Please input a numerical whole number greater than zero");
  73.       }
  74.     if(candy<12)
  75.        {
  76.         printf("\n Not enough candy, Please enter 12 or more");
  77.        }
  78.     if((floor(pidgey)!=pidgey))/*if the rounded down value entered doesn't equal a whole number it prompts an error message to user*/
  79.       {
  80.          printf("\n Please enter a whole number greater than zero for pidgeys");
  81.        }
  82.      if((floor(candy)!=candy))/*if the rounded down value entered doesn't equal a whole number it prompts an error message to user*/
  83.        {
  84.          printf("\n Please enter a whole number greater than 12 for candys");
  85.         }
  86.        
  87.     }
  88. }