<mosaic.cnfolio.com>
PROGRAM
1. /*
2.      START
3.         Enter values for number of pidgeys candys, pidgeys, rattata candys and rattata
4.         If any of the values entered are negative number
5.            Print error message
6.         If the number of pidgeys is less than 1 or number of pidgey candeys is less than 12
7.            Then set pidgeyxp to 0
8.            Else calculate candys needed to evolve all pidgeys
9.         If number of candys is equal or greater than number of pidgey candys needed to evolve all pidgeys
10.            Then calculate XP earned from evolution
11.         Else if pidgey candys is less than candys Needed to elvolve pidgeys and pidgey candys is greater and equal 12 then calculate xp
12.
13.         If the number of rattata is less than 1 or number of pidgey candeys is less than 25
14.            Then set rattataxp to 0
15.            Else calculate candys needed to evolve all rattata
16.         If number of candys is equal or greater than number of rattata candys needed to evolve all rattata
17.            Then calculate XP earned from evolution
18.         Else if ratttata candys is less than candys Needed to elvolve rattata and rattata candys is greater and equal 25 then calculate xp
19.
20.            Then print total value of xp and all individual contributions from pidgey and rattata
21.
22.      END
23. */
24.
25. #include <stdio.h>
26.
27. int main(void)
28. {
29.     int pidgeycandys = 0;
30.     int pidgeys = 0;
31.     int rattatacandys = 0;
32.     int rattata = 0;
33.     int rattataxp = 0;
34.     int pidgeyxp = 0;
35.     int candysNeededpidgeys = 0;
36.     int candysNeededrattata = 0;
37.
38.     scanf("%d %d %d %d",&pidgeycandys, &pidgeys, &rattatacandys, &rattata);
39.     /* scan for all variable values*/
40.
41.     if (pidgeycandys <= 0 || pidgeys <= 0 ||rattatacandys <=0 || rattata <=0 )
42.     {
43.         printf("Negative number has been entered, ERROR with input value.");
44.     /* Error message shows when lower values than 0 are enter into variables */
45.     }
46.        if (pidgeycandys < 12 || pidgeys == 0)
47.        {
48.           pidgeyxp = 0;
49.        }
50.        else
51.        {
52.           candysNeededpidgeys = pidgeys * 12;
53.
54.           if (pidgeycandys >= candysNeededpidgeys)
55.           {
56.              pidgeyxp = pidgeys * 1000;
57.           }
58.           else if (pidgeycandys < candysNeededpidgeys && pidgeycandys >= 12)
59.           {
60.              pidgeyxp = (pidgeycandys/12) * 1000;
61.           }
62.        }
63.        /* if statments above calculates the number of pidgeys that can be evoled and the Xp */
64.
65.        if (rattatacandys < 12 || rattata == 0)
66.        {
67.           rattataxp = 0;
68.        }
69.        else
70.        {
71.           candysNeededrattata = rattata * 25;
72.
73.           if (rattatacandys >= candysNeededrattata)
74.           {
75.              rattataxp = rattata * 1000;
76.           }
77.           else if (rattatacandys < candysNeededrattata && rattatacandys >= 25)
78.           {
79.             rattataxp = (rattatacandys/25) * 1000;
80.           }
81.        }
82.        /* if statments above calculates the number of pidgeys that can be evoled and the Xp */
83.     printf("Total XP, that can be earned is (%d). With %d from rattata and %d from pidgey.", (rattataxp+pidgeyxp), rattataxp, pidgeyxp );
84.        /* print the total value of Xp*/
85.   }