一、Description

Farmer John made a profit last year! He would like to invest it well but wonders how much money he will make. He knows the interest rate R (an integer between 0 and 20) that is compounded annually at his bank. He has an integer
amount of money M in the range 100..1,000,000. He knows how many years Y (range: 0..400) he intends to invest the money in the bank. Help him learn how much money he will have in the future by compounding the interest for each year he saves. Print an integer
answer without rounding. Answers for the test data are guaranteed to fit into a signed 32 bit integer.

Input

* Line 1: Three space-separated integers: R, M, and Y

Output

* Line 1: A single integer that is the number of dollars FJ will have after Y years.

二、题解

       题目的提示很明显,计算过程如下:

 INPUT DETAILS:

      5% annual interest, 5000 money, 4 years

OUTPUT DETAILS:

Year 1: 1.05 * 5000 = 5250

Year 2: 1.05 * 5250 = 5512.5

Year 3: 1.05 * 5512.50 = 5788.125

Year 4: 1.05 * 5788.125 = 6077.53125

The integer part of 6077.53125 is 6077.

     需要注意的是计算过程中间结果要用double存放。

三、java代码

import java.util.Scanner;

  public class Main {

	  public static void main(String[] args)  {
Scanner sc = new Scanner(System.in);
int r,m,y,i;
double result,r1;
r=sc.nextInt();
m=sc.nextInt();
y=sc.nextInt();
r1=0.01 * r+1;
result=m;
for(i=0;i<y;i++){
result*=r1;
}
System.out.println((int)result);
}
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

poj 2390 Bank Interest(计算本利和)的更多相关文章

  1. Bank Interest

    Bank Interest Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Tota ...

  2. 1755: [Usaco2005 qua]Bank Interest

    1755: [Usaco2005 qua]Bank Interest Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 187  Solved: 162[Su ...

  3. bzoj1755 [Usaco2005 qua]Bank Interest

    Description Farmer John made a profit last year! He would like to invest it well but wonders how muc ...

  4. POJ 2398 - Toy Storage - [计算几何基础题][同POJ2318]

    题目链接:http://poj.org/problem?id=2398 Time Limit: 1000MS Memory Limit: 65536K Description Mom and dad ...

  5. POJ 2390

    import java.util.*; public class Main { public static void main(String args[]){ double interest; Sca ...

  6. Jack Straws POJ - 1127 (几何计算)

    Jack Straws Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5428   Accepted: 2461 Descr ...

  7. poj 3304 Segments(计算几何基础)

      Segments Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11593   Accepted: 3657 Descr ...

  8. poj 1519 Digital Roots (计算根数字)

    一.Description The digital root of a positive integer is found by summing the digits of the integer. ...

  9. Jack Straws POJ - 1127 (简单几何计算 + 并查集)

    In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table ...

随机推荐

  1. bash编程基础

    bash变量 变量命名: 1.不能使用程序中的关键字(保留字) 2.只能使用数字.字母和下划线,且不能以数字开头 3.要见名知义 变量类型: 数值型:精确数值(整数),近似数值(浮点型) 字符型:ch ...

  2. 18.Django原生SQL语句查询返回字典

    在django中执行自定义语句的时候,返回的结果是一个tuple ,并我不是我所期望的dict.当结果是tuple 时,如果要取得数据,必须知道对应数据在结果集中的序号,用序号的方式去得到值. 如果是 ...

  3. tf.InteractiveSession()与tf.Session()

    tf.InteractiveSession():它能让你在运行图的时候,插入一些计算图,这些计算图是由某些操作(operations)构成的.这对于工作在交互式环境中的人们来说非常便利,比如使用IPy ...

  4. Linux中查找文件和文件内容的常用命令

    一.whereis <程序名称> 查找软件的安装路径-b 只查找二进制文件 -m 只查找帮助文件-s 只查找源代码-u 排除指定类型文件-f 只显示文件名-B <目录> 在指定 ...

  5. 每天一个Linux命令(27)gzip命令

    zip命令用来压缩文件.gzip是个使用广泛的压缩程序,文件经它压缩过后,其名称后面会多处“.gz”扩展名.     (1)用法:     用法:  gzip [选项参数][-s <压缩字尾字符 ...

  6. hd acm1061

    Problem Description Given a positive integer N, you should output the most right digit of N^N.   Inp ...

  7. 第一天 格式化操作符 条件、for、while、break、continue语句

    python2和3的区别: 2中的print 不必加括号 3中的print变为函数 要加括号   2中的input不能输入字母(输入的字母被认为是变量,而之前又没定义,所以报错),默认只能计算数字,要 ...

  8. 总结最近写的h5项目

    其实最近最大的感触就是真正独立完结一个项目的人学到的东西是最多,但并不意味着自己已全部吸收,还是得消化消化 最近做了一个移动端的h5页面,感兴趣的可以访问看一看:http://app.500jia.c ...

  9. JavaWeb -- 服务器传递给Servlet的对象 -- ServletConfig, ServletContext,Request, Response

    1.  ServletConfig  有一些东西不合适在程序中写死,应该写在web.xml中,比如 文字怎么显示, 访问数据库名 和 密码, servlet要读取的配置文件 等等.. l在Servle ...

  10. Python- 贪婪与非贪婪

    python运行匹配时,如果没有人为限定,默认是贪婪模式. import re a = 'python 22222java34bigdata' r = re.findall('[a-z]{3}',a) ...