<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. PSUEDOCODE
  3.  
  4. START
  5.    READ two numbers from user
  6.    IF input numbers are correctly formatted
  7.       THEN
  8.          IF number of candies is less than 12
  9.             THEN
  10.                Display too few candies error
  11.                Ask for another number
  12.          ELSE
  13.             Calculate number of evolutions that can be performed
  14.             Multiply number of evolutions by Pidgey evolution xp
  15.             Display that number
  16.    ELSE
  17.       IF number is less than zero
  18.          THEN
  19.             Display less than or equal to zero error
  20.      
  21.       ELSE IF not a number
  22.          THEN
  23.             Display not a number error
  24.       ELSE IF missing input
  25.          THEN
  26.             Display missing input message
  27.       END IF
  28.  
  29. END
  30.  
  31. END PSUEDOCODE
  32.      
  33.  
  34. Program should ask the user for the number of pidgeys to be evolved and the
  35. number of candies. The program should then check for any errors with both inputs and display relevant error messages.
  36. On completion of this, the program should then work out if evolutions are
  37. possible and then display the xp from the evolution with and without using a
  38. lucky egg. (double xp)
  39.  
  40. To do:
  41.    Looping for more than one calculation
  42.    Some form of string handling for inputs like "one, two, thirty five" etc
  43.    Evolutions in the form of [pidgey > evolution 2 > evolution 3] and option to pick (using array)
  44.    
  45. */
  46. #include <stdio.h>
  47.  
  48. int main (void)
  49. {
  50.    float pokecounter = 0.0, candy;        /* initialisation of variables */
  51.    int totalxp;
  52.    
  53.    printf("How many Pidgey's to be evolved? > ");
  54.    scanf(" %f", &pokecounter);         
  55.    printf("\nHow many candies do you have? > ");
  56.    scanf(" %f", &candy);
  57.    printf("\n");            /* Pidgey and candy inputs */
  58.    
  59.    if(pokecounter < 0 || candy < 0)   /* Test for inputs less than zero */
  60.    {
  61.       printf("-----> Please use positive values\n");
  62.       return 0;
  63.      
  64.    }
  65.    else if (pokecounter - (int) pokecounter > 0 ||candy - (int) candy > 0  )  /*Test for whole numbers */
  66.    {
  67.       printf("-----> Please enter full numbers\n");
  68.       return 0;
  69.  
  70.    }
  71.    else
  72.       if(candy < 12)   /* Small warning to let the user know that no evolutions will happen */
  73.       {
  74.          printf("-----> Too few candy available to evolve any pokemon\n-----> Starting value must be greater than or equal to 12\n");
  75.          
  76.       }
  77.       else
  78.          for(;candy >= 12 && pokecounter > 0;candy++)   /* calculations. Take 12 candy per evolution and adds 1 back to candy pool, decrements pokecounter and adds 500xp to total */
  79.          {                /* amount of pokemon and candy is checked so that they dont fall below invalid values*/
  80.             totalxp += 500;
  81.             candy -= 12;
  82.             pokecounter -= 1;
  83.          }
  84.          printf("Amount of base experience earned: %d.\nAmount of experience earned with the lucky egg bonus: %d\n", totalxp, totalxp * 2);
  85.          printf("Amount of unevolved pokemon: %.0f\n", pokecounter);
  86.          printf("Leftover Candy: %.0f", candy);     /*displays relevant information for user*/
  87.          return 0;
  88.    
  89. }