代码:
import java.util.Scanner;
public class Work03 {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
int[] price = new int[4];
System.out.println("请输入4家店的价格");
System.out.print("第1店的价格:");
price[0] = input.nextInt();
int min = price[0];
for(int i = 1;i<price.length;i++) {
System.out.print("第"+(i+1)+"店的价格:");
price[i] = input.nextInt();
if(price[i]<min) {
min = price[i];
}
}
System.out.println("最低价格是:"+min);
}
}
运行结果: