Java Program Challenge-Suitcase Packing

Mr. Square is going on holiday. He wants to bring 2 of his favorite squares with him, so he put them in his rectangle suitcase.

Write a function that, given the size of the squares and the suitcase, return whether the squares can fit inside the suitcase.

fit_in(a,b,m,n)
a,b are the sizes of the squares
m,n are the sizes of the suitcase

Example
fit_in(1,2,3,2) should return True
fit_in(1,2,2,1) should return False
fit_in(3,2,3,2) should return False
fit_in(1,2,1,2) should return False

Code:

package com.company;

import static java.lang.Integer.max;

public class suitcase {
    public static boolean FitIn(int a,int b, int m, int n){
        if (a+b<=max(m,n)){
            System.out.println("True");
        }
        else {
            System.out.println("False");
        }
        return false;
    }
    public static void main(String[] args){
        FitIn(1,2,3,2);
        FitIn(1,2,2,1);
        FitIn(3,2,3,2);
        FitIn(1,2,1,2);
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *