<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2.  
  3. Pseudo code
  4.  
  5. START
  6.    Display "XP converter"
  7.    
  8.    read the imputs of Pidgeys and Candies
  9.  
  10.    IF pidgeys = a interger and candies = a interger and pidgeys > 0 and candies > 0
  11.    
  12.        THEN
  13.                WHILE the number of candys >= 12
  14.             
  15.                      reduce the number candys by 11
  16.          
  17.                      Add one to evoulotuons possible
  18.          
  19.                 END WHILE
  20.    
  21.    
  22.                 IF candies = pidgys
  23.       
  24.                     THEN the number of Pidgys is the number of evolutions possible
  25.    
  26.                 ELSE
  27.                
  28.                 IF candies > pidgys
  29.  
  30.                     THEN the number of Pidgys is the number of evolutions possible
  31.                
  32.                 ELSE
  33.                
  34.                     the number of evolutions possible is the number of candies
  35.  
  36.                  END IF
  37.                  
  38.                  END IF
  39.                  
  40.  
  41.  
  42.  
  43.          Display the number of evolutions possible
  44.  
  45.          Xp = the number of evolutions X 500
  46.  
  47.          display the XP receiveied
  48.          
  49.          Time taken  = (the number evolutions x 26)/60
  50.          
  51.          display the time taken
  52.          
  53.          Time left on the lucky egg = 30 - time
  54.          
  55.          display the time left on the lucky egg
  56.          
  57.          lucky eggs required = Timetaken/30
  58.          
  59.          display the lucky eggs required
  60.          
  61.          Left over candies = the candies from the while statment
  62.          
  63.          display the number of left over candies
  64.          
  65.          left over pidgys = pidgys - evolutions
  66.          
  67.          display the number of left over pidgys
  68.          
  69.          
  70.  
  71.    END IF
  72.    
  73.    
  74.    
  75.    
  76.    
  77.    IF the value of pidgys is a decimal
  78.  
  79.       THEN display an error message
  80.       
  81.    END IF
  82.  
  83.    IF the value of candies is a decimal
  84.          
  85.       THEN display an error message 
  86.          
  87.    END IF
  88.    
  89.  
  90.    IF the value of pidgys is negative
  91.  
  92.       THEN display an error message
  93.       
  94.    END IF
  95.  
  96.    IF the value of candies is a negative
  97.          
  98.       THEN display an error message 
  99.    END IF
  100.    
  101.    
  102.    
  103.    
  104. END
  105.  
  106. */
  107.  
  108.    
  109. #include <stdio.h>
  110.  
  111.  
  112. int main(void)
  113. {
  114. float pidgy, ipidgy, candy, icandy, xcandys,  xp, evolution, xpwe, time, eggs, lcandys, lpidgys, timel;
  115. /* Float has been used  to allow the inputs to be decimals */
  116.    printf("xp converter");   
  117.    
  118.    scanf("%f %f", &ipidgy, &icandy) ;
  119.  
  120.      candy=icandy;
  121.      pidgy=ipidgy;
  122.       
  123.      if((floor(ipidgy) == pidgy) && (floor(icandy) == candy) && (ipidgy > 0) && (icandy > 0)) {
  124. /* This if statment its used to ensure the program comes to a singal end */         
  125.                
  126.                while((candy >=12) && (ipidgy>=1))     
  127.             /* By making sure ipidgy>=1 the while statment will not deduct candys for evolutions that wont happen */
  128.             {
  129.             candy = candy -11;   
  130.                   ipidgy--;
  131.             xcandys++;
  132.             }
  133.                  
  134.                if( xcandys == pidgy){
  135.  
  136.                   evolution = pidgy ; }
  137.    
  138.                else if( xcandys > pidgy) {
  139.    
  140.                   evolution = pidgy ;}
  141.       
  142.                else
  143.    
  144.               evolution = xcandys;
  145.    
  146.              printf("\nMaximuim evolutions possible = %.0f",evolution );
  147.    
  148.    
  149.            xp = evolution * 500;
  150.    
  151.            xpwe = evolution * 1000;
  152.    
  153.            printf("\nXP recived from the max number of evolutions = %.0f",xp);
  154.  
  155.            printf("\nXP recived from the max number of evolutions while a lucky egg is activated = %0.f",xpwe);
  156.                
  157.                time = ((evolution*26)/60);
  158.                
  159.                printf("\nTime taken to complete the evolutions is around %.0f minutes.", time) ;
  160.                
  161.                timel = 30-time;
  162.                
  163.                printf("\nTime left on the final Lucky egg is %.0f minutes", timel);
  164.                
  165.                eggs = (ceil(time/30));
  166.                /* I'm rounding the number lucky eggs up to a whole number as you can't have fraction of eggs*/
  167.              
  168.                
  169.                printf("\nNumber of lucky eggs required %.0f", eggs);
  170.    
  171.                lcandys= candy;
  172.                
  173.                if (lcandys > 0){
  174.                   /* this if statment is to ensure that if there are no candies left over the text dosent appear */
  175.                   printf("\n%.0f Candies are left over.", lcandys);
  176.                }
  177.                
  178.                lpidgys = pidgy - evolution;
  179.                
  180.                if(lpidgys >0){
  181.                   /* this if statment is to ensure that if there are no pidgys left over the text dosent appear */
  182.                  printf("\n%.0f Pidgies are left over.", lpidgys);
  183.                } 
  184.                
  185.    }     
  186.  
  187. else{   /*I am using the else statement to enusre the majority of the program runs in a single if statment */
  188.     if(floor(ipidgy) < pidgy){
  189.        printf("\nPlease insert an exact value of Pidgys.");
  190.         /* By comparing the floored registor to the orignal registor i am able to if it has been when rounded down
  191.         if so the input is not an interger */
  192. }   
  193.        
  194.  
  195.     if(floor(icandy) < candy){
  196.        printf("\nPlease insert an exact value of Candys.");
  197.        
  198. }         
  199.    
  200.     if(ipidgy < 1){
  201.        printf("\nPlease insert a positive value of Pidgys.");
  202.        /* by asking if the input is less then 1 we can insure it is a positive whole number */
  203. }
  204.    
  205.     if(icandy < 1){
  206.        printf("\nPlease insert a positive value of Candys.");
  207.        
  208.        /*Useing nested logic the user interface is more informative
  209.        as i am able to provied detailed error messages. */
  210. }
  211.  
  212. }
  213.  
  214. }