<mosaic.cnfolio.com>
PROGRAM
1. /*
2. START
3.    Set the value for "pidgeycandy" to zero
4.    Set the value for "numberofpidgeys" to zero
5.    Set the value for "totalxp" to zero
6.    GET the user input for "pidgeycandy"
7.    GET the user input for "numberofpidgeys"
8.
9.    IF values for "pidgeycandy" is less than 11
10.    THEN
11.       Display the error messsage "Not enough Canides"
12.    END IF
13.
14.    IF the values for "numberofpidgeys" is less than or equal to 0
15.    THEN
16.       Dispaly the error message "Not enough Pidgeys"
17.    END IF
18.
19.    WHILE the total amount of "numberofpidgeys" is more than 0 AND
20.    the total amount of "pidgeycandy" is more than or equal to 12
21.       Add 500 to "totalxp" then times by 2
22.       Minus 11 from "pidgeycandy"
23.       Minus 1 from "numberofpidgeys"
24.    END WHILE
25.
26.    Display text "Average evalutions per egg 60-90."
27.
28.    IF the "numberofpidgeys" output is negative
29.    THEN
30.      Display values for "pidgeycandy" +11
31.      Display values for "numberofpidgeys"
32.      Display values for "totalxp" - 1000
33.    ELSE
34.      Display values for "pidgeycandy"
35.      Display values for "numberofpidgeys"
36.      Display values for "totalxp"
37.
38.    END IF
39.
40. END
41. */
42.
43. #include <stdio.h>
44.
45. int main (void) {
46.
47.    int pidgeycandy = 0;
48.    int numberofpidgeys = 0;
49.    int totalxp = 0;
50.
51.    scanf ("%d", &pidgeycandy);
52.    scanf ("%d", &numberofpidgeys);
53.
54.    switch (pidgeycandy)
55.    {  case 11: case 10: case 9: case 8: case 7: case 6:
56.       case 5: case 4: case 3: case 2: case 1: case 0:
57.       printf ("Not enough candies.")/* Using a Switch()Case, compaired to an IF,
58.    because it can guarantee error checking. Because of it using interger values if a
59.    non-interger value is entered the error message will appear.*/
60.       default:
61.       break;
62.    }
63.
64.    switch (numberofpidgeys)
65.    {  case 0:
66.       printf ("   Not enough pidgeys.");
67.       default:
68.       break; /* The defualt value just allows the program to continue, as the breake allows
69.       the exit of the Switch()Case. */
70.    }
71.
72.    while(numberofpidgeys >0, pidgeycandy >= 12) /* This while loop is used, compaired to
73.    FOR loops, as there are more then one conditions that need to be met. DO-WHILE loops would require
74.    addititonal coding and will have to run at least once, compaired to the while WHILE*/
75.    {
76.    numberofpidgeys = numberofpidgeys - 1;
77.    totalxp = totalxp + 500 *2 ;
78.    pidgeycandy = pidgeycandy - 11 ;
79.    }
80.
81.       printf ("\nAverage Evalutions Per Lucky Egg is between 60-90.");/*This is here to provide information
82.    to the user. \n allows for a new line.*/
83.
84.  if (numberofpidgeys <0) /*Prevention when the output becomes negative. */
85.    {
86.       printf ("\nCandy Left: %d, Pidgeys Left:0, XP gained: %d", pidgeycandy+11, totalxp-1000);
87.    }
88.  else
89.    {
90.       printf ("\nCandy Left: %d, Pidgeys Left: %d, XP gained: %d", pidgeycandy, numberofpidgeys, totalxp);
91.
92.    }
93. }