Advertisement
Kvarz

Correct Change

Jan 7th, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static boolean doStuff(int nickels, int pennies, int sum){
  6.        
  7.         nickels*=5;
  8.         int allSum = nickels+pennies;
  9.         boolean answer = false;
  10.        
  11.         //System.out.println(allSum);
  12.         if(allSum==sum){
  13.             answer = true;
  14.         }
  15.         else if(allSum<sum) {
  16.             answer = false;
  17.         }
  18.         else if(allSum>sum){
  19. //that's where all important things happens!
  20.  
  21.             answer = false;
  22.            
  23.            
  24.            
  25.            
  26.            
  27. //face THE END
  28.         }
  29.         return answer;
  30.     }
  31.  
  32.     public static void main(String[] args) {
  33.        
  34.  
  35.         //int n = in.nextInt();
  36.         int n = 1;
  37.         for(int i=0; i<n; i++){
  38.             Scanner in = new Scanner(System.in);
  39.             int a = in.nextInt();
  40.             int b= in.nextInt();
  41.             int c = in.nextInt();
  42.             System.out.println( doStuff(a, b, c) );
  43.            
  44.             //in.close();
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement