import java.util.Scanner; public class A01 { public static void main(String[] args) { // TODO Auto-generated method stub int count=0; int Age=0; Scanner input = new Scanner (System.in); for (int i = 0; i <10; i++) { System.out.println("请输入第"+(i+1)+"位顾客的年龄:"); Age=input.nextInt(); if(Age>0&&Age<=30){ count++; } } System.out.println("30岁以下的比例:"+count/10.0*100+"%"); System.out.println("30岁以上的比例:"+(1-count/10.0)*100+"%"); } }
java-第五章-for-计算顾客比例,布布扣,bubuko.com
原文地址:http://1797077217.blog.51cto.com/8956560/1420816