一、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. iOS 字符串截取,将字符串中用括号包含的内容去除

    //去除字符串中用括号括住的位置 -(NSString *)handleStringWithString:(NSString *)str{ NSMutableString * muStr = [NSM ...

  2. centos下安装pip时失败:

    [root@wfm ~]# yum -y install pipLoaded plugins: fastestmirror, refresh-packagekit, securityLoading m ...

  3. Swift编程语言学习6—— 闭包

    闭包是自包括的函数代码块,能够在代码中被传递和使用. Swift 中的闭包与 C 和 Objective-C 中的代码块(blocks)以及其它一些编程语言中的 lambdas 函数比較类似.   闭 ...

  4. js实现select动态添加option

    关于 select 的添加 option 应该注意的问题. 标准的做法如上也就是说,标准的做法是 s.options.add();但是如果你一定要用 s.appendChild(option);注意了 ...

  5. 每天一个Linux命令(3)mkdir命令

        mkdir命令用来创建目录.    (1)用法:  用法: mkdir [选项]... 目录... (2)功能: 功能: 若指定目录不存在则创建目录 该命令创建由dirname命名的目录.如果 ...

  6. 【leetcode刷题笔记】Linked List Cycle II

    Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Foll ...

  7. sql优化,索引学习

  8. 大话设计模式--享元模式 Flyweight -- C++实现实例

    1. 享元模式: 运用共享技术有效地支持大量细粒度的对象. 享元模式可以避免大量非常相似类的开销,在程序设计中,有时需要生成大量颗粒度的类实例来表示数据,如果能发现这些实例除了几个参数外基本都是相同的 ...

  9. java:练习学校学生

    java:练习学校学生 一个学生对应一个学校 一个学校对应多个学生 Student类,School类,Demo测试类 Student: public class Student { private S ...

  10. 分享知识-快乐自己:PageHelper 分页关键基础代码

    关键代码:点我下载样式   详细介绍 //使用分页插件 jQuery("#pagination").pagination(data.total, { items_per_page: ...