我的任务是编写一个程序,该程序采用两个整数并使用一种名为 Min 的方法打印较小的整数值用户的输入是相等的。
谢谢
import java.util.Scanner;
public class Min
{
public static void main(String[]args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter First Number: ");
int fnumber = in.nextInt();
System.out.print("Enter Second Number: ");
int snumber = in.nextInt();
int result = min(fnumber,snumber);
System.out.println(result + " Has the smaller Value ");
}
public static int min (int n1, int n2)
{
if (n2 < n1)
{
return n2;
}
else
{
return n1;
}
}
}