<mosaic.cnfolio.com>
PROGRAM
1. /* Pseudo Code
2. Start
3.   Initialize all the values to zero apart from Pidgey and Candies
4.   Display the welcome message
5.   Read the number of Pidgey and Candies
6.   IF Pidgey is equal to less than zero
7.     Display an errror message
8.   END IF
9.   IF Pidgey and Candies are greater than one
10.   WHILE END = 0
11.     DO
12.       IF Pidgey is greater than one
13.       IF Candies are greater than twelve
14.         Perform the evolution calculation
15.         XP + 1000
16.         -1 Pidgey
17.         -12 Candies
18.         +1 Candies
19.       END IF
20.       ELSE
21.       IF the number of Candies and Pidgey-1 = twelve
22.         Then transfer of the Pidgey can happen
23.         Transfer = 12(total cost of one evolution) - Candies
24.         Pidgey = Pidgey - total cost of one evolution
25.         Candies = Candies + total cost if one evolution
26.       END IF
27.       ELSE
28.         Go to END
29.       END ELSE
30.       END IF
31.       END IF
32.    END WHILE
33.    Display the final XP message
34.    Display the total times taken to perform the evolution
35. END
36. */
37.
38. #include <stdio.h>
39.
40. int main (void)
41. {
42.  int Pidgey;
43.  int Candies;
44.  int XP = 0;
45.  int end = 0;
46.  int total_cost = 0;
47.  int trans = 0;
48.  int timer = 0;
49.
50.  printf("\nWelcome to Pokemon GO XP calculator\n"); /*Welcome message which a player will recieve when using the program*/
51.  scanf("%d %d" , &Pidgey, &Candies);         /*The user has to enter their numbers in order to run the program*/
52.
53. if (Pidgey <= 0)
54. {
55.    printf("You need at least one Pidgey to continue");    /*Error message will appear when the player doesn't have enough Pidgey*/
56.    end = 1;
57. }
58.
59. if (Pidgey >= 1 && Candies >= 1)
60. {                                  /*Start of the while loop*/
61.    do
62.    {
63.       if (Pidgey >= 1)
64.       {
65.
66.          if ( Candies >= 12 )     /*Evolution calculation*/
67.          {
68.          XP = 1000 + XP;
69.
70.          Candies - 12;
71.
72.          Pidgey --;
73.
74.          Candies = Candies ++;
75.
76.          timer =  timer + 22.2;
77.          }
78.
79.          else
80.          {
81.             if (Candies + (Pidgey - 1 ) >= 12)   /*Transfer calculation for when a player doesn't have enough supplies*/
82.             {
83.             trans = 12 - Candies;
84.
85.             Pidgey = Pidgey - trans;
86.
87.             Candies = Candies + trans;
88.             }
89.             else
90.             {
91.             end = 1;
92.             }
93.           }
94.         }
95.         else
96.         {
97.         end = 1;
98.         }
99.        }
100.
101.    while (end == 0);         /*Finish point of the while loop*/
102.
103.    printf("\nCongratulations you will be able to get %d XP!\n", XP);   /*Message which will show the player how much XP they will be able to recieve*/
104.    printf("\nTime taken evolving: %.2lf minutes!\n", timer*0.016);     /*Message which will show the player the time taken to perform the evolutions*/
105.    }
106.  }