<mosaic.cnfolio.com>
PROGRAM
1. /*
2. START
3.       Collect the number of Pokemon that the user has, the number of Candies and the Tier of the Pokemon
4.    IF there is a whole, positive number of Candies, Pokemon and if the tier is between 1 and 5
5.    THEN
6.       WHILE the number of candies is greater than or equal to the number of candies needed per evolutions
7.          take the number of candies required per evolution from the number of candies remaining
8.          add one to both candies and evolution
9.       END WHILE
10.    ELSE
11.       IF the number of evolutions is less than the number of pokemon
12.       THEN
13.          Set the number of evolutions to be the number of pokemon
14.          XP = number of evolutions x 1000
15.          Display the total number of Evolutions possible, the XP gained, the number of pokemon left and the number of candies left
16.     END IF
17.       IF there is not a whole, positive number of Candies
18.       THEN
19.          Prompt the user to enter a whole, positive number of Candies
20.       END IF
21.       IF there is not a whole positive number of pokemon
22.       THEN
23.          Prompt the user to enter a whole, positive number of Pokemon
24.       END IF
25.       IF the value for tier is not between 1 and 5
26.       THEN
27.          Prompt the user to enter a number between 1 and 5
28.       END IF
29.    END IF
30. END
31. */
32. #include <stdio.h>
33. int main (void)
34. {
35.    float Pokemon, Candies, Pokemonleft, XP; /*These are float values because the user could input any number and xp could be very large */
36.    int level = 1, Evolutions = 0;/* Set the tier to 1 so that if the user doesn't input anything then it will default to 1 */
37.    int CandyNumber[5] = {12,25,50,100,400}; /* An array showing all the numbers of candy needed for an evolution for each tier of pokemon */
38.    printf("Enter the number of Pokemon, candies and the tier of the pokemon that you have, if you are using Pidgeys you don't have to enter a tier");
39.    scanf("%f %f %d", &Pokemon, &Candies, &level);
40. if( (floor(Candies) == Candies) && (floor(Pokemon)==Pokemon) && (Pokemon >=1) && (Candies >=1) && (level >= 1)&& (level <= 5))
41. {
42.    while(Candies >= (CandyNumber[(level-1)]) &&  (Pokemon>=1))
43. {
44.    Candies = Candies - CandyNumber[(level-1)];/* the level-1 part accounts for the zero indexed array*/
45.    Evolutions++; /*Increments the number of evolutions*/
46.    Candies++; /*Accounts for the bonus candy gained when an evolution occurs*/
47.    Pokemon--;
48. }
49.    XP = Evolutions * 1000;
50.    printf("%d",Evolutions);
51.    printf("\nYou can perform %.0d evolutions and gain %.0f XP \nYou have %.0f Pokemon and %.0f Candies left", Evolutions, XP, Pokemonleft, Candies);
52. }
53. else
54. {
55.    if( (floor(Candies)!=Candies) || (Candies<1))
56.    {
57.      printf("\nPlease enter a whole, positive number of Candies");
58.    }
59.    if((floor(Pokemon)!=Pokemon) || (Pokemon <1))
60.    {
61.       printf("\nPlease enter a whole, positive number of Pokemon");
62.    }
63.    if  ((level < 1)  || (level > 5))
64.    {
65.       printf("\nPlease enter a value between 1 and 5 for the tier");
66.    }
67. }
68. }