我正在学习如何使用 BlueJ,并且正在努力编写代码以输出用户输入的最小数字。任何帮助,将不胜感激!
import java.util.Scanner;
public class FindMin
{
public static void main(String[] args)
{
System.out.print("Program to compare three numbers");
System.out.println("and output minimum value entered");
Scanner input = new Scanner(System.in);
System.out.print("Enter 1st number: ");
int number1;
number1 = input.nextInt();
System.out.print("Enter 2nd number: ");
int number2;
number2 = input.nextInt();
System.out.print("Enter 3rd number: ");
int number3;
number3 = input.nextInt();
int minimum;
if (number2 > number1 | number3 > number1){
minimum = number1;
}
else if (number1 > number2 | number3 > number2){
minimum = number2;
}
else if (number1 > number3 | number2 > number3){
minimum = number3;
}
System.out.print("The minimum of the numbers entered is ");
System.out.println(minimum);
System.out.println();
}
}
心有法竹
吃鸡游戏
梵蒂冈之花
皈依舞
相关分类