class apples{
public static void main(String args[]){
int gas = 4;
int miles = 50000;
int car1 = 15000;
int car2 = 30000;
int mpg1 = 10;
int mpg2 = 50;
int gascost1 = (miles/mpg1) * gas;
int gascost2 = (miles/mpg2) * gas;
int total1 = (car1 + gascost1);
int total2 = (car2 + gascost2);
System.out.println(total1);
System.out.println(total2);
if (total1 < total2)
System.out.println("Buy car 1");
else
System.out.println("Buy car 2");
}
}
這是一個基本的算法,以顯示什麼購買汽車,將長期節省資金。如果任何人都可以提供幫助,那會很棒。 感謝有沒有更簡單的方法來寫這個(java)
我喜歡這個,有沒有辦法清理億元幣。我有? – 2015-02-23 17:39:53