<mosaic.cnfolio.com>
PROGRAM
  1. #include <stdio.h>
  2.  
  3.  
  4.  
  5. int main (void)
  6.  
  7. {
  8.  
  9. int xp=1000;
  10. int quantity= -1; /* The compiler values "quantity" as 1 so do avoid this issue, I valued "quantity" as 1 */ /* Number of Pidgey */
  11. int candy = -1/* The compiler values "candy" as 1 so do avoid this issue, I valued "candy" as 1 */
  12. int pidgeycandy=12;
  13. int enoughcandy;
  14. int evolution;
  15.  
  16. scanf("%d", &quantity);
  17.  
  18. if ( quantity <0)  /* Error Message for quantity input */
  19. {
  20. printf("How many pidgey do you have ? Type a number please.");
  21. }
  22.  
  23. else
  24. {
  25. scanf("%d", &candy); /* Error Message for candy input */
  26.  
  27. if ( candy <=0 )
  28. {
  29. printf("How many candy do you have? Type a number please.");
  30.  
  31. }
  32.  
  33.  
  34. else
  35. {
  36. evolution= ( ( candy / pidgeycandy )   - ( candy - (quantity * pidgeycandy) ) /12);
  37. int counter = 1;
  38.   while(counter <= quantity){    /* While loop for +1 candy */
  39.    
  40.    if ( candy <12)
  41.    break;
  42.  
  43.    
  44.    if ( quantity > 0  )
  45.       candy++;
  46.     counter++;
  47.    
  48.    if ( counter == evolution)
  49.    break;
  50.    
  51.    
  52.   }
  53.  
  54. enoughcandy=( ( quantity * xp ) - ( candy / pidgeycandy ) * xp );
  55. printf("%d",candy) ;
  56.    
  57.  if ( enoughcandy <0 ) /* Calculation part, if there is not enough candy  */
  58. {
  59. printf("\nYou can earn maximum %d"( ( candy / pidgeycandy ) * xp ) - ( candy - (quantity * pidgeycandy) ) /12 * xp);
  60. printf(" xp right now");
  61. printf( "\nYou have extra %d", candy - (quantity * pidgeycandy) );
  62. printf(" candies");
  63. printf("\nYou can earn %d", ( candy - (quantity * pidgeycandy) ) /12 * xp);
  64. printf(" more xp, if you have %d",( candy - (quantity * pidgeycandy) ) /12 );
  65. printf(" more pidgeys ( considering with amount of extra candy you have ) ");
  66.    {
  67.    
  68.    
  69.    if ( ( evolution > 85 ) ) /* You can estimatly evolve 85 pokemon with 1 lucky egg ( 30 minutes )  */
  70.    {
  71.    printf("\nYou may need more than 1 lucky egg to evolve your pokemons");
  72. }
  73.  
  74.    
  75. }
  76.  
  77.  }
  78.    else
  79. {   
  80. printf("\nYou can earn maximum %d"( candy / pidgeycandy ) * xp ); /* Calculation part, if there is enough candy  */
  81. printf(" xp right now");
  82.  
  83.  
  84. if ( evolution > 85 )
  85.    {
  86.    printf("\nYou may need more than 1 lucky egg to evolve your pokemons");
  87. }
  88.  
  89. }
  90.  
  91. }
  92.  
  93. }
  94. }