import static org.junit.Assert.*;
import java.math.BigDecimal;
import org.junit.Test;
public class test {
@Test
public void fulitest(){
System.out.print("
复利: ");
double wh = new fuli().CalculateA(100,1,0.2,2);
System.out.print(wh);
BigDecimal b = new BigDecimal(wh);
wh = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
boolean test=false;
if(wh-121.00==0)
test=true;
else
test=false;
assertEquals(true,test);
}
@Test
public void danlitest(){
System.out.print("
单利: ");
double wh = new danli().CalculateA(100,1,0.2);
System.out.print(wh);
BigDecimal b = new BigDecimal(wh);
wh = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
boolean test=false;
if(wh-120.00==0)
test=true;
else
test=false;
assertEquals(true,test);
}
@Test
public void benjintest(){
System.out.print("
本金: ");
double wh = new benjin().CalculateA(200,3,0.2,2);
System.out.print(wh);
BigDecimal b = new BigDecimal(wh);
wh = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
boolean test=false;
if(wh-112.89==0)
test=true;
else
test=false;
assertEquals(true,test);
}
@Test
public void huankuantest(){
System.out.print("
还款: ");
double wh = new huankuan().CalculateA(200,0.2,10);
System.out.print(wh);
BigDecimal b = new BigDecimal(wh);
wh = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
boolean test=false;
if(wh-48.00==0)
test=true;
else
test=false;
assertEquals(true,test);
}
@Test
public void lilvtest(){
System.out.print("
利率: ");
double wh = new lilv().CalculateA(100,200,2,3);
System.out.print(wh);
BigDecimal b = new BigDecimal(wh);
wh = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
boolean test=false;
if(wh- 0.37==0)
test=true;
else
test=false;
assertEquals(true,test);
}
@Test
public void shijiantest(){
System.out.print("
时间: ");
double wh = new shijian().CalculateA(100,200,0.2,1);
System.out.print(wh);
BigDecimal b = new BigDecimal(wh);
wh = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
boolean test=false;
if(wh-3.80==0)
test=true;
else
test=false;
assertEquals(true,test);
}
@Test
public void touzitest(){
System.out.print("
投资: ");
double wh = new touzi().CalculateA(100,0.2,3);
System.out.print(wh);
BigDecimal b = new BigDecimal(wh);
wh = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
boolean test=false;
if(wh-436.80==0)
test=true;
else
test=false;
assertEquals(true,test);
}
}
更新说明:本程序由C转Java版,并和252王俊杰同学合作完成。
合作伙伴:http://www.cnblogs.com/wangjunjie123/p/5336224.html