<mosaic.cnfolio.com>
PROGRAM
1. /*
2. START
3.    Scan input for number of Pokemon, number of Candies, and Pokemon selection number
4.
5.    IF The number of Pokemon is not an integer
6.       THEN
7.          Display message: "The number is not an integer. Enter a positive integer for number of Pokemon"
8.       ELSE
9.          Carry on with code
10.    END IF
11.
12.    IF The number of Candies is not an integer
13.       THEN
14.          Display message: "The number is not an integer. Enter a positive integer for number of Candies"
15.       ELSE
16.          Carry on with code
17.    END IF
18.
19.    IF The Pokemon Selection number is not an integer
20.       THEN
21.          Display message: "The value entered is not an integer. Please enter 1, 2 or 3 to select pokemon calculator"
22.                           "Insert number 1 for Pidgey, 2 for Rattata and 3 for Pikachu calculator"
23.       ELSE
24.          Carry on with code
25.    END IF
26.
27.    IF The Pokemon selection number is 1
28.       THEN
29.          Display message: "You have selected the Pidgey calculator. You have entered X number of Pidgeys and Y number of Pidgey Candies"
30.          (Where X=Amount of pokemon entered by user, Y=The amount of candies entered by user)
31.       ELSE
32.       Move on to next selection number check
33.    END IF
34.
35.    IF The amount of Pidgeys is less than 0, or the amount of Candies is less than zero
36.       THEN
37.          Display Message: "Enter a positive numerical integer for Pidgeys and Candies"
38.       ELSE
39.          Divide the amount of candies by 12 (As each Pidgey requires 12 candies to evolve)
40.    END IF
41.
42.    IF The solution from the last sum is greater than the amount of pidgeys entered by the user
43.       THEN
44.          The amount of Pidgeys able to evlove is the amount of pidgeys entered by the user
45.       ELSE
46.          Carry on with code
47.    END IF
48.
49.    IF The solution from the last sum is less than the amount of pidgeys entered by the user
50.       THEN
51.          The amount of pidgeys able to evolve is the amount of pidgeys from the output of the sum used.
52.          Remaining Candies = (Candie amount)-(Evolved Pidgey amount/12)+(Evolved pidgey amount)
53.          Evolved pidgey amount added on as you recieve 1 candie for evolving each Pidgey
54.          XP gained = (Evolved Pidgey amount)*500
55.          XP gained using a lucky Egg = (XP gained)*2
56.          As a lucky egg doubles the amount of XP you gain
57.          Display Message:"You Have Evolved 'A' Pidgeys, giving you 'B' XP, and 'C' XP with a Lucky Egg"
58.             Where A= The amount of Pidgeys Evolved, B=The amount of XP gained without a lucky egg,
59.             C=The amount of XP gained with a lucky egg
60.          Display Messgae:"You have 'D' amount of Candies remaining"
61.             Where D=The amount of candies remaining as calculated
62.    END IF
63.
64.    IF The Pokemon selection number is 2
65.       THEN
66.          Display message: "You have selected the Rattata calculator. You have entered X number of Rattata and Y number of Rattata Candies"
67.          (Where X=Amount of pokemon entered by user, Y=The amount of candies entered by user)
68.       ELSE
69.          Move on to next selection number check
70.    END IF
71.
72.    IF The amount of Rattata is less than 0, or the amount of Candies is less than zero
73.       THEN
74.          Display Message: "Enter a positive numerical integer for Rattata and Candies"
75.       ELSE
76.          Divide the amount of candies by 25 (As each Rattata requires 25 candies to evolve)
77.    END IF
78.
79.    IF The solution from the last sum is greater than the amount of Rattata entered by the user
80.       THEN
81.          The amount of Rattata able to evlove is the amount of Rattata entered by the user
82.       ELSE
83.          Carry on with code
84.    END IF
85.
86.    IF The solution from the last sum is less than the amount of Rattata entered by the user
87.       THEN
88.          The amount of Rattata able to evolve is the amount of Rattata from the output of the sum used.
89.          Remaining Candies = (Candie amount)-(Evolved Rattata amount/25)+(Evolved Rattata amount)
90.          Evolved Rattata amount added on as you recieve 1 candie for evolving each Rattata
91.          XP gained = (Evolved Rattata amount)*500
92.          XP gained using a lucky Egg = (XP gained)*2
93.          As a lucky egg doubles the amount of XP you gain
94.          Display Message:"You Have Evolved 'A' Rattata, giving you 'B' XP, and 'C' XP with a Lucky Egg"
95.             Where A= The amount of Rattata Evolved, B=The amount of XP gained without a lucky egg,
96.             C=The amount of XP gained with a lucky egg
97.          Display Messgae:"You have 'D' amount of Candies remaining"
98.             Where D=The amount of candies remaining as calculated
99.    END IF
100.
101.    IF The Pokemon selection number is 3
102.       THEN
103.          Display message: "You have selected the Pikachu calculator. You have entered X number of Pikachu and Y number of Pikachu Candies"
104.          (Where X=Amount of pokemon entered by user, Y=The amount of candies entered by user)
105.       ELSE
106.          Move on to next selection number check
107.    END IF
108.
109.    IF The amount of Pikachu is less than 0, or the amount of Candies is less than zero
110.       THEN
111.          Display Message: "Enter a positive numerical integer for Pikachu and Candies"
112.       ELSE
113.          Divide the amount of candies by 50 (As each Pikachu requires 50 candies to evolve)
114.    END IF
115.
116.    IF The solution from the last sum is greater than the amount of Pikachu entered by the user
117.       THEN
118.          The amount of Pikachu able to evlove is the amount of Pikachu entered by the user
119.       ELSE
120.          Carry on with code
121.    END IF
122.
123.    IF The solution from the last sum is less than the amount of Pikachu entered by the user
124.       THEN
125.          The amount of Pikachu able to evolve is the amount of Pikachu from the output of the sum used.
126.          Remaining Candies = (Candie amount)-(Evolved Pikachu amount/50)+(Evolved Pikachu amount)
127.          Evolved Pikachu amount added on as you recieve 1 candie for evolving each Pikachu
128.          XP gained = (Evolved Pikachu amount)*500
129.          XP gained using a lucky Egg = (XP gained)*2
130.          As a lucky egg doubles the amount of XP you gain
131.          Display Message:"You Have Evolved 'A' Pikachu, giving you 'B' XP, and 'C' XP with a Lucky Egg"
132.             Where A= The amount of Pikachu Evolved, B=The amount of XP gained without a lucky egg,
133.             C=The amount of XP gained with a lucky egg
134.          Display Messgae:"You have 'D' amount of Candies remaining"
135.             Where D=The amount of candies remaining as calculated
136.    END IF
137.
138.    IF There is no value entered for Pokemon selector
139.      THEN
140.          Display Message: "You have not selected a calculator"
141.       ELSE
142.         Set all values back to zero
143.    END IF
144.
145. END
146. */
147.
148. #include <stdio.h>
149. int main(void)
150.
151. {
152.
153.    int poke=0, candy=0, Evpoke=0, remain_candies=0, XP=0, LEXP=0, XEvpoke=0, select=0;          /*Declare these variables as integers, and make them all =0 to make sure there are no random values if nothing is inputted*/
154.    float pokefloat=0, candyfloat=0, selectfloat=0;                                              /*Decalre these varibles as 4 bytes, with six digits of decimal precision*/
155.
156.
157.
158.    scanf("%f %f", &pokefloat, &candyfloat);                   /*Scan the input for two values. The first being the amount of Pokemon and the second the amount of candies the user has for that Pokemon*/
159.    scanf("%f", &selectfloat);                                                                   /*scan for a third value which is the number used to select the type of Pokemon the user needs to calculate*/
160.
161.    poke=(int)pokefloat;                                                                         /*Make the value of variable 'poke' equal to the rounded down integer value of the Pokemon scanned from the input*/
162.    ++poke;                              /*Add 1 to the value of poke*/
163.    if ((poke - pokefloat) != 1)                       /*If the number of Pokemon minus the input Pokemon value is not equal to one (Meaning the inputted value was not a positive integer)*/
164.    {
165.       printf("The number is not an integer. Enter a positive integer for number of Pokemon\n"); /*Print this message on the output*/
166.       return 0;                                                                                 /*Stop the code at this point as there is no need to proceed further*/
167.    }
168.    else
169.    {
170.       pokefloat = --poke;                                                /*Else, if the number of Pokemon minus the input Pokemon value is equal to one, make the number of Pokemon equal to the value inputted (as it is an integer)*/
171.    }
172.
173.    candy=(int)candyfloat;                                                /*Make the value of variable 'candy' equal to the rounded down integer value of the Candies scanned from the input*/
174.    ++candy;                             /*Add 1 to the value of Candies*/
175.    if ((candy - candyfloat) != 1)                                                               /*If the number of Pokemon minus the input Pokemon value is not equal to one (Meaning the inputted value was not a positive integer)*/
176.    {
177.       printf("The number is not an integer. Enter a positive integer for number of Candies\n")/*Print this message on the output*/
178.      return 0;                                                      /*Stop the code at this point as there is no need to proceed further*/
179.    }
180.    else
181.    {
182.       candyfloat = --candy;
183.    }                                                              /*Else, if the number of Pokemon minus the input pokemon value is equal to one, make the number of Candies equal to the value inputted (as it is an integer)*/
184.
185.    select=(int)selectfloat;                                                                     /*Make the value of variable 'select' equal to the rounded down integer value of the selection scanned from the input*/
186.    ++select;                            /*Add 1 to the value of select*/
187.    if ((select - selectfloat) != 1)                     /*If the number of select minus the input sleect value is not equal to one (Meaning the inputted value was not a positive integer)*/
188.    {
189.       printf("The value entered is not an integer. Please enter 1, 2 or 3 to select pokemon calculator\n")/*Print this message on the output*/
190.       printf("Insert number 1 for Pidgey, 2 for Rattata and 3 for Pikachu calculator\n");   /*Print this message on the output also*/
191.       return 0;                                                                                 /*Stop the code at this point as there is no need to proceed further*/
192.    }
193.    else
194.    {
195.       selectfloat = --select;                       /*Else, if the number of select minus the input select value is equal to one, make the number of select equal to the value inputted (as it is an integer)*/
196.    }
197.
198.
199.
200.    if (select == 1)                           /*If the 'select' number is equal to 1, this means that the code will prceed as a Pidgey calculator*/
201.    {
202.       printf("You have selected the Pidgey calculator. You have entered %d number of Pidgeys and %d number of Pidgey Candies \n", poke, candy)/*print the statement below inserting the value of pokemon, and the value of candies*/
203.
204.       if (poke<=0 || candy<=0 )                       /*If the number of pokemon is equal to or less than 0, or the number of candies is equal to or less than zero*/
205.       {
206.          printf("Error: Enter a positive numerical integer for Pidgeys and Candies\n");       /*print the error message*/
207.          return 0;                                                                              /*stop the code at this point as there is no need to proceed further*/
208.       }
209.
210.       XEvpoke=candy/12;                                                                         /*The number of pokemon that can be potentially evolved is = (candy inputted by user/12)*/
211.       if  (XEvpoke>=poke)                                                 /*If the amount of pokemon that can be potentially evolved is greater or equal than the amount of pokemon inputted*/
212.       {
213.          Evpoke = poke;                                                                         /*Then the amount of pokemon that can be evolved is equal to the amount of pidgeys inputted by the user*/
214.       }
215.       if (poke>=XEvpoke)                                                 /*If the amount of pokemon that can be potentially evolved is less than or equal to the amount of pokemon inputted*/
216.       {
217.          Evpoke = XEvpoke;                                                                      /*Then the amount of pokemon that can be evolved is equal to the amount of potential amount calculated on line 210*/
218.       }
219.       remain_candies=(candy-(Evpoke*12)+Evpoke);                                                /*The amount of candies remaining after the evolutions is = (candies inputted by user)-(The amount of evolved Pokemon*25)+(The amount of pokemon evolved). The amount of pokemon evolved is added on as you recieve
220.                                                                                                    1 candie for each evolution of that type of pokemon*/
221.       XP= Evpoke*500;                                                   /*The amount of XP (Experience points) recieved is = (Amount of pokemon evolved)*500. As each evolution is worth 500 XP*/
222.       LEXP = XP*2;                                                                              /*The amount of XP recieved using a lucky egg is = XP*2 as you recieve double XP using a lucky egg*/
223.       printf ("You Have Evolved %d Pidgeys, giving you %d XP, and %d XP with a Lucky Egg\n", Evpoke, XP, LEXP);   /*Print the message as shown. Replacing the "%d" with the amount of Pokemon evolved, the amount of XP gaines and the amount of XP gained using a lucky egg respectively (The "/n" means add a new line for the next print)*/
224.       printf("You have %d Pidgey Candies remaining", remain_candies);                   /*Print the message shown. Replacing "%d" with the remaining candies*/
225.
226.    }
227.
228.
229.    else if (select == 2)                                                 /*If the 'select' number is equal to 2, this means that the code will proceed as a Rattata calculator*/
230.    {
231.       printf("You have selected the Rattata calculator. You have entered %d number of Rattata and %d number of Rattata Candies \n", poke, candy)/*print the statement below inserting the value of pokemon, and the value of candies*/
232.
233.       if (poke<=0 || candy<=0)                                                                  /*If the number of Pokemon is equal to or less than 0, or the number of candies is equal to or less than zero*/
234.       {
235.          printf("Error: Enter a positive numerical value\n");                        /*print the error message*/
236.          return 0;                                                                              /*stop the code at this point as there is no need to proceed further*/
237.       }
238.
239.       XEvpoke=candy/25;                         /*The number of Pokemon that can be potentially evolved is = (candy inputted by user/25)*/
240.       if  (XEvpoke>=poke)                                                                        /*If the amount of Pokemon that can be potentially evolved is greater or equal than the amount of Pokemon inputted*/
241.       {
242.          Evpoke = poke;                         /*Then the amount of Pokemon that can be evolved is equal to the amount of pidgeys inputted by the user*/
243.       }
244.       if (poke>=XEvpoke)                                                                        /*If the amount of pokemon that can be potentially evolved is less than or equal to the amount of pokemon inputted*/
245.       {
246.      Evpoke = XEvpoke;                                                /*Then the amount of pokemon that can be evolved is equal to the amount of potential amount calculated in line 239*/
247.       }
248.       remain_candies=(candy-(Evpoke*25)+Evpoke);                                                /*The amount of candies remaining after the evolutions is = (candies inputted by user)-(The amount of evolved Pokemon*25)+(The amount of pokemon evolved). The amount of pokemon evolved is added on as you recieve
249.                                                                                                    1 candie for each evolution of that type of pokemon*/
250.       XP= Evpoke*500;                                                                           /*The amount of XP (Experience points) recieved is = (Amount of pokemon evolved)*500. As each evolution is worth 500 XP*/
251.       LEXP = XP*2;                                                                              /*The amount of XP recieved using a lucky egg is = XP*2 as you recieve double XP using a lucky egg*/
252.       printf("You Have Evolved %d Rattata, giving you %d XP, and %d XP with a Lucky Egg\n", Evpoke, XP, LEXP)/*Print the message as shown. Replacing the "%d" with the amount of Pokemon evolved, the amount of XP gaines and the amount of XP gained using a lucky egg respectively*/
253.       printf("You have %d Rattata Candies remaining", remain_candies);                  /*Print the message shown. Replacing "%d" with the remaining candies*/
254.
255.    }
256.
257.    else if (select == 3)                                                                        /*If the 'select' number is equal to 3, this means that the code will proceed as a Pikachu calculator*/
258.    {
259.       printf("You have selected the Pikachu calculator. You have entered %d number of Pikachu and %d number of Pikachu Candies \n", poke, candy)/*print the statement below inserting the value of pokemon, and the value of candies*/
260.
261.       if (poke<=0 || candy<=0)                                                                  /*If the number of Pokemon is equal to or less than 0, or the number of candies is equal to or less than zero*/
262.       {
263.          printf("Error: Enter a positive numerical value\n");                        /*print the error message*/
264.          return 0;                                                                              /*stop the code at this point as there is no need to proceed further*/
265.       }
266.
267.       XEvpoke=candy/50;                         /*The number of Pokemon that can be potentially evolved is = (candy inputted by user/50)*/
268.       if  (XEvpoke>=poke)                                                                        /*If the amount of Pokemon that can be potentially evolved is greater or equal than the amount of Pokemon inputted*/
269.       {
270.          Evpoke = poke;                         /*Then the amount of Pokemon that can be evolved is equal to the amount of pidgeys inputted by the user*/
271.       }
272.       if (poke>=XEvpoke)                                                                        /*If the amount of pokemon that can be potentially evolved is less than or equal to the amount of pokemon inputted*/
273.       {
274.          Evpoke = XEvpoke;                        /*Then the amount of pokemon that can be evolved is equal to the amount of potential amount calculated in line 267*/
275.       }
276.       remain_candies=(candy-(Evpoke*50)+Evpoke);                                                /*The amount of candies remaining after the evolutions is = (candies inputted by user)-(The amount of evolved Pokemon*25)+(The amount of pokemon evolved). The amount of pokemon evolved is added on as you recieve
277.                                                                                                    1 candie for each evolution of that type of pokemon*/
278.       XP= Evpoke*500;                                                                           /*The amount of XP (Experience points) recieved is = (Amount of pokemon evolved)*500. As each evolution is worth 500 XP*/
279.       LEXP = XP*2;                                                                              /*The amount of XP recieved using a lucky egg is = XP*2 as you recieve double XP using a lucky egg*/
280.       printf ("You Have Evolved %d Pikachu, giving you %d XP, and %d XP with a Lucky Egg\n", Evpoke, XP, LEXP);   /*Print the message as shown. Replacing the "%d" with the amount of Pokemon evolved, the amount of XP gaines and the amount of XP gained using a lucky egg respectively*/
281.       printf("You have %d Pikachu candies remaining", remain_candies);                  /*Print the message shown. Replacing "%d" with the remaining candies*/
282.
283.    }
284.    else
285.    {
286.       printf("You have not selected a calculator\n");               /*Else, if the inputted value is not 1,2 or 3, print the message shown in the code*/
287.    }
288.
289.
290.
291.    return 0;                                                                                    /*Stop the code at this point*/
292. }