每天一道算法_6_I Think I Need a Houseboat
今天的题目是I Think I Need a Houseboat
如下:

21.0 1.025.0 0.0
Property 1: This property will begin eroding in year 1.Property 2: This property will begin eroding in year 20.END OF OUTPUT.
import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class IThinkINeedaHouseboat {public static void main(String args[]){double PI = 3.1415926;int year = 1;float area = 0;int year_count = 0;Scanner in = new Scanner(System.in);int all = in.nextInt();int count = all * 2;List<Float> list = new ArrayList<Float>();while(count > 0){count--;list.add(in.nextFloat());}for(int i = 0; i<list.size(); i = i + 2){year_count ++;area = (float) (PI*(list.get(i) * list.get(i) + list.get(i + 1) * list.get(i + 1))/2);for(year = 1; year * 50 < area; year ++){}System.out.println("Property "+ year_count + ": This property will begin eroding in year " + year + ".");}System.out.println("END OF OUTPUT.");}}
作者:jason0539
微博:http://weibo.com/2553717707
博客:http://blog.csdn.net/jason0539(转载请说明出处)