Using if/else statement, creaaate a method in Java that will assign…