<mosaic.cnfolio.com>
PROGRAM
1. /*PSEUDO CODE
2. START
3.    Initialise all variables to the value 0
4.    Display a welcome message
5.    Display instructions on how to use the program
6.    SCAN assign the 3 user inputs to appropriate variables
7.
8.    DEFAULT TO PIDGEY EVOLVE COSTS IF 2 VALUES ENTERED
9.
10.    IF 3 variables are entered
11.       THEN
12.       IF the pokemon value and candies value are both greater than 0
13.          THEN
14.             IF the pokemon type is 1 for Pidgey
15.                THEN
16.                   set the evolvec variable to 12 (evolve cost)
17.                ELSE IF the pokemon type is 2 for Rattata
18.                   THEN
19.                      set the evolvec variable to 25 (evolve cost)
20.                ELSE IF the pokemon type is 3 for Zubat
21.                   THEN
22.                      set the evolvec variable to 50 (evolve cost)
23.       END IF
24.
25.       IF evolvec variable is greater than 0
26.          THEN
27.             WHILE end variable is equal to 0
28.                DO
29.                   IF there is more than or equal to 1 pokemon
30.                   IF there are more candies or equal to the cost of evolving
31.                      THEN
32.                         perform calculations for evolving
33.                         remove 1 pokemon
34.                         add 1000 to xp value
35.                         add 1 candies for evolving
36.                         add 22.2 seconds to evolve time
37.                   ELSE
38.                      IF the sum of candies and pokemon-1 is greater than or equal to evolve cost
39.                         THEN
40.                            perform calculations for transferring pokemon
41.                            assign the value of evolvec-candies to transferp
42.                            assign the value of pokemon-transferp to pokemon
43.                            assign the value of candies+transferp to candies
44.                         ELSE
45.                            END the program
46.                   ELSE
47.                      END the program
48.             END IF
49.              END WHILE
50.              Display the amount of experience points earned
51.              Display the amount of pokemon remaining
52.              Display the amount of candies remaining
53.              Display the amount of time taken to complete
54.       ELSE
55.          Display error message
56.       END IF
57.    ELSE
58.       Display error message
59.    END IF
60. END
61. */
62.
63. #include <stdio.h>
64.
65. int main( void )
66. {
67. int pokemontype = 1/* Initialising all variables to zero to ensure a reset each time */
68. int matchinput = 0;
69. int pokemon = 0;
70. int candies = 0;
71. int xp = 0;
72. int evolvec = 0;
73. int transferp = 0;
74. int end = 0;
75. int time = 0;
76.
77. printf("\nWelcome to the Pokemon Go XP calculator!\n");              /*Welcome message*/
78. printf("\nPokemon types: 1 = Pidgey, 2 = Rattata, 3 = Zubat\n");        /*Input instruction*/
79. printf("\nEnter number of Pokemon, number of Candies and Pokemon type\n")/*Input instruction*/
80.
81. matchinput = scanf("%d %d %d", &pokemon, &candies, &pokemontype);  /*Scanning for 3 input values*/
82.
83. if (matchinput == 3 || matchinput == 2)         /*Checking 3 inputs have been entered or 2 inputs for pidgey*/
84. {
85. {
86.    if (pokemon >= 0 && candies >= 0)   /*Entering calculation requiring pokemon and candies to be above 0*/
87.    {
88.       if (pokemontype == 1)
89.          evolvec = 12;            /*Assigning the correct evolve cost for a Pidgey*/
90.       else if (pokemontype == 2)
91.          evolvec = 25;            /*Assigning the correct evolve cost for a Rattata*/
92.       else if (pokemontype == 3)
93.          evolvec = 50;            /*Assigning the correct evolve cost for a Zubat*/
94.
95.       if (evolvec > 0)            /*Entering evolve pokemon calculation*/
96.       {
97.          do
98.          {
99.             if (pokemon >= 1)    /*If there is more than 1 pokemon, continue*/
100.             {
101.             if (candies >= evolvec)  /*If there is more candies or equal amount to the evolve cost, continue*/
102.             {
103.                candies = candies - evolvec;
104.                pokemon --;
105.                xp = xp + 1000;
106.                candies ++;
107.                time = time + 22.2;
108.             }
109.             else                /*If there is less than 1 pokemon available, continue*/
110.             {
111.                if (candies + (pokemon-1) >= evolvec)    /*Entering pokemon transfer calculation*/
112.                {
113.                   transferp = evolvec - candies;
114.                   pokemon = pokemon - transferp;
115.                   candies = candies + transferp;
116.                }
117.                else
118.                {
119.                   end = 1;  /*No more pokemon available for transfer, finished*/
120.                }
121.             }
122.             }
123.          else
124.          {
125.             end = 1;    /*No more candies available to evolve, finished*/
126.          }
127.          }
128.
129.       while (end == 0);   /*Continue looping through calculations until no more evolutions or transfers can happen*/
130.       {
131.       printf("\nYou will recieve %d XP\n", xp);         /*Displaying final results*/
132.       printf("\nYou will have %d Pokemon remaining\n", pokemon);
133.       printf("\nYou will have %d candies remaining\n", candies);
134.       printf("\nYou will spend %.2lf minutes evolving!\n", time*0.016);
135.       }
136.       }
137.       else
138.          printf("Please only enter 1, 2 or 3 for pokemon type");    /*Pokemon type input error message*/
139.       }
140.    else
141.       printf("Please only enter positive integers for number of pokemon and candies")/*Pokemon and candies input error message*/
142.    }
143.    }
144. else
145.    printf("Please enter 3 seperate integers for number of pokemon, candies and type of pokemon")/*General input error message*/
146. }