编写一个程序来计算单利,并且必须使用单独的方法来返回计算并进行计算。
public class Unit7B
{
public static void main ( String [ ] args )
{
double p = Input.getDouble ("Enter the principal");
double i = Input.getDouble ("Enter the interest rate");
double n = Input.getDouble ("Enter the number of years");
double result = simpleInterest( p, i, n);
System.out.println (result);
}
public double simpleInterest (double p, double i, double n)
{
return ( p * ( Math.pow ( 1.0 + i , n ) ));
}
}