Kvarz

Correct Change I learneroo

Jan 11th, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 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.         //your code here
  7.         boolean answer = false;
  8.         int n = sum/5;
  9.     //  System.out.println(n);
  10.         int p = sum - n*5;
  11.     //  System.out.println(p);
  12.         if(n<=nickels && p<=pennies){
  13.             answer = true;
  14.         }
  15.         else answer = false;
  16.        
  17.         return answer;
  18.     }
  19.  
  20.     public static void main(String[] args) {
  21.         Scanner in = new Scanner(System.in);
  22.  
  23.         int n = in.nextInt();
  24.         for(int i=0; i<n; i++){
  25.             int a = in.nextInt();
  26.             int b= in.nextInt();
  27.             int c = in.nextInt();
  28.             System.out.println( doStuff(a, b, c) );
  29.         }
  30.     }
  31. }
Add Comment
Please, Sign In to add comment