对前一个程序的响应,只需放置新的余额();公共静态无效的主要是,不起作用,没有该程序运行,但nerver打印出用户的问题!如何调用方法到主要方法(程序运行但不打印问题)(作业)
import java.io.*;
public class cInterest {
public static void main(String[] args) throws IOException
{
//new balance ;
}
public static double balance(double principal, double rate, double years) throws IOException{
double amount = 0;
String input;
BufferedReader myInput = new BufferedReader (new InputStreamReader (System.in));
System.out.print("How much would you like to take out? ");
input = myInput.readLine();
principal = Double.parseDouble (input);
System.out.print("Enter the interest rate: ");
input = myInput.readLine();
rate = Double.parseDouble (input);
for (int i = 1; i < years; i++) {
amount = principal * rate * years;
amount += principal;
}
return amount; //- principal;
}
}
只是称之为平衡(...); – Dan 2013-03-07 16:43:53
题外话,你几乎肯定希望'我'从0开始。否则,如果你想运行一年(例如),你甚至不会进入循环。 – 2013-03-07 16:52:28