试验4

package com.wuchaghao.test2;

import java.util.Scanner;

public class t2 {
public static void main(String []args ){

Scanner scan = new Scanner(System.in);
System.out.println("请输入一个金额");
double money = scan.nextDouble();
System.out.println("请输入年限");
int year = scan.nextInt();

for(double i = 0.05;i<=0.08;i+=0.00125){
System.out.print("利率:"+i);
double monthper = i/12;
double monthmoney = (money*monthper)/(1-(1/(Math.pow((1+monthper), (year*12)))));
System.out.print("月还款:"+monthmoney);
System.out.println("总还款:"+monthmoney*12*year);

}

}

}

 

 

 

 

package com.wuchanghao.test1;

import java.util.Scanner;

public class t1 {
public static void main(String[] args){

while(true){
System.out.println("请输入一个数");
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
double sum= 0;

for(int i = 1;i<=num;i++){
tools ts = new tools();
sum = sum+ts.getnum(i);
}
System.out.println("结果是:"+4*sum);
}
}

}


package com.wuchanghao.test1;

public class tools {
public double getnum(int i){
double result = 0.00;
if((i%2)!=0){
result = (1/(double)(2*i-1));
}
else{
result = -(1/(double)(2*i-1));
}
return result;
}

}

 

posted on 2016-10-17 11:06  天才程序猿  阅读(80)  评论(0编辑  收藏  举报

导航