获取最低价手机价格–0703

代码:

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); } }

运行结果:

技术图片

 

相关文章