编写一个程序,接受用户想要输入的整数。确定最高和最低数字,并从最高数字中减去所有其他数字。我无法理解差异。我知道这里不见了。请帮我。
import java.util.*;
//Misty Stewart
public class HighestLowestDifference2324 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double maxValue = Double.MIN_VALUE;
double minValue = Double.MAX_VALUE;
double minValue1 = Double.MAX_VALUE;
double minValue2 = Double.MAX_VALUE;
int count = 0;
double difference = 0;
System.out.println("Enter numbers. Terminate with Q.");
while (input.hasNextDouble()) {
double Value = input.nextDouble();
if (Value > maxValue) {
maxValue = Value;
}
if (Value < minValue) {
minValue = Value;
}
if (Value < minValue) {
minValue1 = Value;
}
if (minValue == minValue1) {
minValue = Value;
}
if (Value < minValue1) {
minValue2 = Value;
}
if (minValue1 == minValue2) {
minValue1 = Value;
}
}
count++;
difference = maxValue - minValue;
{
if (count > 0) {
System.out.println("Highest no. is: " + maxValue);
System.out.println("Lowest no. is: " + minValue);
System.out.println("The difference from the highest is: \n" + difference);
} else {
System.out.println("Have a good day!");
}
}
}
}