<mosaic.cnfolio.com>
PROGRAM
  1. /* Pseudo Code of Program
  2.  
  3. First read the two inputs
  4. Next work out If you have enough candy, e.g it is above 12, by using an if statment
  5. Next calculate the maximum possible evolutions from the amount of candy, 12 candy to one pidgy.
  6. Now multiply the amount of evolutions to calculate the exp
  7. finally display the exp, amount of pokemon and candies left and or any error messages.
  8. This is acheived with multiple sets of If and Else If statments that will either end the program and display an error messages or eill run its full course and calulate the EXP */
  9.  
  10.  
  11. #include <stdio.h>   /* required directory */
  12.  
  13. int main ()
  14. {
  15.  
  16. int Pidgeys, Candy, *p, *q, sum, sum2, sum3, sum4, sum5, sum6 ; /* Variable definition, defines the different variables that could be used throughout the program */
  17.  
  18.  
  19.    printf("Enter Number Of Pidgeys And Number Of Candies\n"); /* asking for an input through printing */
  20.    scanf("%d%d", &Pidgeys, &Candy); /* scanning the input for the 2 random input intergers */
  21.  
  22.  
  23.  
  24. p = &Pidgeys;
  25.    
  26. q = &Candy;
  27.  
  28. if( *q < 0){ /* this set of if statments will produce error messages for invalid inputs */
  29.               printf("Invalid Number Of Candies, Please Enter A Number Above 0\n" );
  30.               }
  31.   else if (*p < 1) {
  32.               printf("Invalid Number Of Pokemon Please Enter A Number Above 0\n" );
  33.               }
  34.   else if ( *q < 12) {
  35.               printf("You Do Not Have Enough Candies To Evolve A Pidgey, You Require 12\n" );
  36.   }
  37.   else {
  38.  
  39.         sum = *q / 12;
  40.                      if ( sum > *p){ /* these further statments will produce the output exp, amount of pokemon left and the amount of candy left */
  41.                         sum2 = *p * 1000;
  42.                      printf ("The Total EXP Available With The Bonus Is %d\n",sum2);
  43.                      }
  44.                      else {
  45.                      sum2 = sum * 1000;
  46.                      printf ("The Total EXP Available With The Bonus Is %d\n",sum2);
  47.                      }
  48.                      
  49.                      if ( *q > *p) {
  50.                       sum3 = *p * 12;
  51.                       sum4 = *q - sum3;
  52.                         if ( sum4 > 0) {
  53.                         printf ("The Amount of Candy Left Is %d\n",sum4);
  54.                        
  55.                       }
  56.                         else if ( *p = sum) {
  57.                         printf ("The Amount of Candy Left Is 0, There are also no Pidgeys left");
  58.                         }
  59.                         else{
  60.                         sum5 = *p / 12;
  61.                         sum6 = *q - sum5;
  62.                         printf ("The Amount of Candy Left Is %d\n",sum6);
  63.                         }
  64.                       }
  65.                      
  66.                       else if( *p > *q) {
  67.                        sum3 = *p - sum;
  68.                        sum4 = sum * 12;
  69.                        sum5 = *q - sum4;
  70.                       printf ("The Amount of Candy Left Is %d\n",sum5);
  71.                       printf ("The Amount of Pidgeys Left Is %d\n",sum3);
  72.                      
  73.                       }
  74.                      
  75.        }
  76.    
  77.    return 0;
  78. }