1. /*
  2. START
  3.    Read the first number put into the box, my code sets this to be the number of pokemon you have.
  4.    Read the second number in the text box, this will be the number of candies you have to evolve your pokemon.
  5.    Read the text put as the third bit in the text box, this will choose which pokemon you wish to evolve. (it can be left blank, defaulting in pidgey)
  6.       WHILE the value of "Nnamecheck" is less that 71 (which is the total number of avaliable pokemon)
  7.          IF the name of the pokemon in the text box is the same as the name of the pokemon at the position equal to the number of times its checked the name in the list
  8.             THEN Note that the pokemon name is real and note how many checks it had to do to find the same name.
  9.             ELSE Increase the number of "Nnamecheck" by one and go back to the while loop.
  10.          END IF
  11.       END WHILE
  12.    The number of candy required for the chosen pokemon to evolve is the same number of entries along in a seperate list as the name itself was.   
  13.    The number of candies required to evolve a pokemon is orginally 12/25/50/100/400 but after an evolution has happened you are refunded one, so its the same as saying the number of candies needed is the number from the list but minus 1
  14.       IF the text put into the text box after the number of pokemon and candies is a real name of a pokemon
  15.          THEN
  16.             IF the number of candies and pokemon put in are 1 or above
  17.                THEN
  18.                   IF The number of candies and pokemon are whole numbers (the rounded down value is the same as the original)
  19.                      THEN
  20.                         WHILE the number of candies are above the amount needed to evolve the pokemon and the number of pokemon is above 0
  21.                            Decrease the number of total candies by the amount needed for one evolution
  22.                            Decrease the number of pokemon by 1
  23.                            Increase the number of complete evolutions by 1
  24.                         END WHILE
  25.                         The time taken to evolve (in seconds) is equal to the number evolutions times by 30 (30 seconds of animations for an evolution to take place)
  26.                         Time in minutes is above divided by 60
  27.                         The amount of xp you will get is 1000 times the number of evolutions
  28.                         The number of lucky eggs needed is the number of minutes taken to evolve divided by 30 (they last 30 minutes) but rounded up as 31 minutes will require 2 eggs
  29.                         IF the number of eggs is more than 1
  30.                            THEN When printed inclues and "s" on the end of eggs to count in plural
  31.                         END IF
  32.                         IF the number of candies left over is more than one
  33.                            THEN replace the end of the word cand"y" with "ies" to account for plural
  34.                         END IF
  35.                         IF the amount of time take in minutes is not one
  36.                            THEN include "s" at the end of minute when it is printed
  37.                         END IF
  38.                         IF the number of evolutions is greater than one
  39.                            THEN add and "s" on the end of the word evolution when printed
  40.                         END IF
  41.                         Print the number of candies needed to evolve once
  42.                         Print the number of complete evolutions that can take place
  43.                         Print the number of candies left over after the evolutions
  44.                         Print the amount of experience is generated through the evoltions with and without a lucky egg
  45.                         Print the number of minutes the total number of evoltions will take and print the number of lucky eggs will be requires to maintian the times 2 bonus throughou
  47.                      ELSE display an error message saying the code only accepts whole numbers
  48.                   END IF
  49.                ELSE display and error message saying only positive values can be put into the code
  50.             END IF
  51.          ELSE display an error saying a real pokemon name is required for the code to work
  52.       END IF 
  53.       END
  54. */  
  56. #include <ctype.h>
  57. #include <stdio.h>
  58. #include <string.h>
  59. #include <math.h>
  61. int main (void)
  62. {
  63.    float InputN=0, CandyN=0, CandySubtract=0, TimeM=0, EggCalc=0;
  64.    char pokemon[70][16]={"Caterpie","Weedle","Pidgey","Eevee","Bulbasaur","Charmander","Squirtle","Rattata","Nidoran","Oddish","Poliwag","Abra","Machop","Bellsprout","Geodude","Gastly","Dratini","Metapod","Kakuna","Pidgeotto","Spearow","Ekans","Pikachu","Sandshrew","Clefairy","Vulpix","Jigglypuff","Zubat","Paras","Venonat","Diglett","Meowth","Psyduck","Mankey","Growlithe","Tentacool","Ponyta","Slowpoke","Magnemite","Doduo","Seel","Grimer","Shellder","Drowzee","Krabby","Voltorb","Exeggcute","Cubone","Koffing","Rhyhorn","Horsea","Goldeen","Staryu","Omanyte","Kabuto","Ivysaur","Charmeleon","Wartortle","Nidorina","Nidorino","Gloom","Poliwhirl","Kadabra","Machoke","Weepinbell","Graveler","Haunter","Dragonair","Magikarp","\0"};
  65.    /*Saving a list of names in a 2 dimensional array with a maximum number of 70 different pokemon and a max of 16 letters in a pokemon name, ended with a null character*/
  66.    char pokename[16]={"Pidgey"}; /*Sets the default pokemon to pidgey if no specific pokemon is input*/
  67.    char EggName, Timeplural, Evolutionplural;
  68.    char candyplural[3]={"ies"};
  69.    char candyend[3]={"y"};
  70.    int Nnamecheck=0,pokenum=0,Evolution=0, XP=0, TimeS=0, EggNo=0, pokemonreal=0;
  71.    int candyrequired[70]={12,12,12,25,25,25,25,25,25,25,25,25,25,25,25,25,25,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,100,100,100,100,100,100,100,100,100,100,100,100,100,400};
  72.    scanf("%f %f %s", &InputN, &CandyN, pokename);
  73.    pokename[0]=toupper(pokename[0]);
  75.       for(Nnamecheck=0;Nnamecheck < 71; Nnamecheck++)/* runs a check for text for every name saved in the array until the correct one is found*/
  76.      {
  77.        if(strcmp(pokename,pokemon[Nnamecheck])==0); /*compares the whole text to a whole text saved in the array*/
  79.          {
  80.            pokenum = Nnamecheck;
  81.             pokemonreal=1;/*arbitary value to tell me if the name has been seen and therefor eif the inputted name is a true pokemon name*/
  82.          }
  83.       }
  85.     CandySubtract=candyrequired[pokenum];
  86.     CandySubtract=CandySubtract-1;/* after an evolution takes place one candy is given back for the new pokemon*/
  88.     if (pokemonreal==1) /* as said above in the for loop*/
  89.     {   
  90.     if ((InputN>=1)&&(CandyN>=1)) /*if the value is greater than one then it is not negative also a value of 0 would be pointless and unuseable*/
  91.       {
  92.          if ((CandyN==floor(CandyN)) && (InputN==floor(InputN))) /*if the rounded down value of a number is not the same as its original it cannot be an integer*/
  93.             {
  94.             while(CandyN>CandySubtract && InputN>0) /*as long as there are enough pokemon and candies to evolve this will loop */
  95.                {
  96.                CandyN=CandyN-CandySubtract;
  97.                InputN=InputN-1;
  98.                Evolution=Evolution+1;
  99.                }
  101.                TimeS = Evolution*30;
  102.                TimeM = TimeS/60.0;
  103.                XP=Evolution*1000; /*one evolution with an egg active will award 1000 experience*/
  104.                EggCalc = TimeM/30;
  105.                EggNo = ceil(EggCalc);/*if the time taken is just 1 second over 30 mins it will require another egg, therefore rounded up is the best way to solve this*/
  106.                if (EggNo>1)
  107.                {
  108.                EggName = 's';/* if the value is multiple the letter s will be input to account for plurals */
  109.                }
  110.                if (CandyN>1)
  111.                {
  112.                strcpy(candyend,candyplural); /* replaces one word with the other */
  113.                }
  114.                if (TimeM!=1)
  115.                {
  116.                Timeplural='s';
  117.                }
  118.                if (Evolution>1)
  119.                {
  120.                Evolutionplural='s';
  121.                }
  122.                printf("To Complete This Evolution Once, You Need %d Candies", candyrequired[pokenum]);/* print all related values to calculations*/
  123.                printf("\nYou Can Complete %d Evolution%c", Evolution, Evolutionplural);
  124.                printf("\nYou Will Have %.0f Cand%s Left Over", CandyN, candyend);
  125.                printf("\nYou Will Earn %d Experience With A Lucky Egg", XP);
  126.                printf("\nYou Will Earn %d Experience Without A Lucky Egg", XP/2);
  127.                printf("\nIt Will Take %.1f Minute%c", TimeM, Timeplural);
  128.                printf(" And Will Therefore Need %d Lucky Egg%c If Chosen ", EggNo, EggName);
  129.             }
  130.          else
  131.             {
  132.             printf ("\n Please Enter Integer Values For Both Variables"); /* appropriate error messages for each check */
  133.             }
  134.     }
  135.     else
  136.       {
  137.        printf ("\n Please Enter Positive Values For Both Variables");
  138.       }
  139.       }
  140.     else
  141.     {
  142.     printf("\n Please Enter A Real Pokemon Name");
  143.     }
  144. }