【0703作业】获取最低价手机价格

 1 package com.workprojects;
 2 /**
 3  * 求出4家店的最低手机价格
 4  *2019-07-03
 5  * @author L
 6  *
 7  */
 8 
 9 import java.util.Scanner;
10 
11 public class Work070303 {
12     static Scanner sc = new Scanner(System.in);
13     public static void main(String[] args) {
14         System.out.println("请输入4家店的价格:");//输入提示
15         int []price=new int[4];//四家店,数组长度为4
16         for(int i=0;i<price.length;i++) {
17             System.out.print("第"+(i+1)+"家店的价格是:");
18             price[i]=sc.nextInt();
19         }
20         int min=price[0];
21         for(int i =0;i<price.length;i++) {
22             if(min>price[i]) {
23                 min=price[i];
24             }
25         }
26         System.out.println("最低价格是:"+min);
27     }
28 }

猜你喜欢

转载自www.cnblogs.com/yanglanlan/p/11134054.html