<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3.    Enter number of pidgeys
  4.    Enter number of candy
  5.    Assign first input value to variable pidgey
  6.    Assign second input value to variable candy
  7.    
  8. IF value for pidgeys is missing
  9.    THEN
  10.       Display error message telling the user to input the amount of pidgeys they own
  11. END IF
  12. IF value for candy is missing
  13.    THEN
  14.       Display error message telling the user to input the amount of candy they own
  15. END IF
  16. ELSE IF inputted number of candy is less than 12
  17.    THEN
  18.       Display error message stating you need at least 12 candy to evolve pidgey pokemon
  19. END IF
  20. ELSE IF inputted number of pidgeys is less than 1
  21.    THEN
  22.       Display an error message stating that you need at least 1 pidgey to evolve
  23. END IF
  24. IF both the inputted number of candy is more than or equal to 12 and the number of pidgeys is more than or equal to 1
  25.    THEN
  26.       WHILE pidgeys is greater than or equal to 1 AND candy is greater than or equal to 12
  27.          Decrease number of pidgeys by 1
  28.          Increase counter by 1
  29.          Decrease number of candies by 11
  30.       END WHILE
  31.      
  32. Display the value of the counter as the number of pidgeys that can be evolved
  33. Multiply the value of the counter by 1000 and store as xp
  34. Display the amount of xp the player will gain
  35. Display the number of pidgeys and candy left over after evolutions
  36. Display the average amount of time it will take to evolve the pidgeys in seconds
  37. END
  38. */
  39.  
  40. #include <stdio.h> /* Defines the stdio (standard input/output header file for the program to use. */
  41. int main(void) /* Defines the main function of the program as an integer value of void. The program ends when the main function finishes. */
  42. {
  43.  
  44. int time; /* Defining the time variable as a double data type for use when calculating the amount of time it will take to evolve all available pidgeys. */
  45. int pidgeys = 0; /* Stores the amount of pidgeys that the player owns when they enter the value as an integer value. */
  46. int candy = 0; /* Defines the variable candy as an integer, which will store the amount of candies that the player inputs. */
  47. int xp; /* Stores the amount of xp that they player will earn by evolving all available pidgeys as an integer value. */
  48. int loop; /* This is the counter value which will increase by 1 every time the while loop loops. It is stored as an integer value. */
  49.  
  50. scanf("%d %d", &pidgeys, &candy); /* Looks for and assigns input data for number of pidgeys and number of candy to their respective variables above. */
  51.  
  52. if (pidgeys == NULL) /* Looks to see if the input value for pidgeys is blank (the user hasn't entered any data) and will display an error message telling them to input a value for how many pidgeys they own. */
  53.    printf("Please enter the number of pidgeys you have in your inventory\n\n");
  54. if (candy == NULL)/* Looks to see if the input value for candy is blank (the user hasn't entered any data) and will display an error message telling them to input a value for how many candy they own. */
  55.    printf("Please enter the number of candy you have in your inventory\n\n");
  56.    else /* If neither of the above if statements are fulfilled, it means that the user has entered some data and will check to see if they meet the requirements below. */
  57. if (candy < 12) /* This if statement looks to see if the inputted value for the number of candy is less than 12, and will print an error message if the value is less than 12 */
  58.    printf("You do not have enough candy to evolve a Pidgey\n\n");
  59.    else
  60. if (pidgeys < 1) /* This if statement looks to see if the inputted value for the number of pidgeys is less than 1, and will print an error message if the value is less than 12 */
  61. printf("You do not have any Pidgeys to evolve\n\n");
  62.  
  63.    
  64. if(pidgeys > 0 && candy >= 12) /* This if statement checks to see if pidgeys is greater than 0 and if the number of candy is greater or equal to 12. This is to make the while loop only run if these conditions are met. */
  65. {
  66.    while ( pidgeys >= 1 && candy >= 12) /* This while loop will loop until the number of pidgeys is less than 1 and the number of candy is les than 12. This while loop is used to calculate how many pidgeys the player is able to evolve using the inputted values for candy and pidgeys.*/
  67.    {
  68.       pidgeys = pidgeys - 1; /* Every time the loop is ran, the number of pidgeys is decreased by 1 to show a pidgey being used for evolving. */
  69.       loop++; /* Every time the loop is ran, the loop variable will increase by 1 so that you are able to know how many times you can evolve. */
  70.       candy = candy - 11; /* Every time the loop is ran, the number of pidgeys is decreased by 11 as the candy is being used for evolving. */
  71.    }
  72. printf("You can evolve a total of %d Pidgeys. This will give you a total of %d XP with a lucky egg.\n\n", loop, xp = loop * 1000); /* Displays the value of the loop variable, which is equal to the number of pidgeys the player is able to evolve based on the input values. It will also display the amount of xp the player will gain from evolving those pidgeys by multiplying loop (the number of evolutions) by 1000xp.*/
  73. printf("You will have %d Pidgeys and %d candy left over.\n\n", pidgeys, candy); /* Displays the number of pidgeys and candy that will be left over after evolving all possible pidgeys. */
  74. printf("It will take an average of %d seconds to evolve %d pidgeys.\n\n", time = loop * 21, loop); /* Displays the estimated amount of time it will take to evolve all possible pidgeys (based on 21 seconds per evolution), by multiplying the number of possible pidgey evolutions by 21 seconds. */
  75. }
  76. }