Write the compare (int a) method to complete the following operations:
-If the method parameter is less than 5, "number less than 5" will be displayed;
-If the method parameter is greater than 5, "number greater than 5" will be displayed;
-If the method parameter is equal to 5, "number equals 5" is displayed.
requirement:
The program should display text on the screen.
The main method should not be called System.out.println Or System.out.print 。
The main method should call the compare method.
The compare method must be void.
The compare method should display text on the screen according to the task conditions.
package zh.codegym.task.task04.task0408;
/*
好还是不好?
*/
public class Solution {
public static void main(String[] args) {
compare(3);
compare(6);
compare(5);
}
public static void compare(int a) {
//在此编写你的代码
if(a<5){
System.out.println("数字小于5");
}
else{
if(a>5){
System.out.println("数字大于5");
}
else{
System.out.println("数字等于5");
}
}
}