Find Number Properties - Java Quiz Question



Write a program to return the properties - isPerfectSquare, isPrimeNumber, previousNumber, nextNumber, square and cube - for the given input number.

Input (Integer) Output (NumberProperites)
25 isPerfectSquare = true
isPrimeNumber = false
previousNumber = 25 - 1 = 24
nextNumber = 25 + 1 = 26
square = 25 * 25 = 625
cube = 25 * 25 * 25 = 15625
7 isPerfectSquare = false
isPrimeNumber = true
previousNumber = 7 - 1 = 6
nextNumber = 7 + 1 = 8
square = 7 * 7 = 49
cube = 7 * 7 * 7 = 343
10 isPerfectSquare = false
isPrimeNumber = false
previousNumber = 10 - 1 = 6
nextNumber = 10 + 1 = 8
square = 10 * 10 = 100
cube = 10 * 10 * 10 = 1000

class FindNumberProperties

{    public static void main(String s[])
    {
        NumberProperties properties = getProperties(7);
        
        System.out.println("Printing the properties of the number 7");
        System.out.println("---------------------------------------");
        System.out.println("Perfect Square : " + properties.isPerfectSquare);
        System.out.println("Prime Number : " + properties.isPrimeNumber);
        System.out.println("Previous Number : " + properties.previousNumber);
        System.out.println("Next Number : " + properties.nextNumber);
        System.out.println("Square : " + properties.square);
        System.out.println("Cube : " + properties.cube);

    }


public static NumberProperties getProperties(int input)
{
//Write code here to create a NumberProperties object. Get the required properties of the input number and assign them to the NumberProperties object. Also return the created object.
}
}
class NumberProperties
{
boolean isPerfectSquare;
boolean isPrimeNumber;
int previousNumber;
int nextNumber;
int square;
int cube;
}