一、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. iPhone快速获取UUID

    1.一张图解决不懂iPhone手机的小白获取UDID的方式

  2. Latex: Expression under summation on multiple lines

    Purpose Describe the sum symbol like this: zebk=1Nk∑i∈Rkj∈W(i)∩Rkmax(fi−fj) Solution code z_{ebk}=\f ...

  3. Hadoop初体验

    1.首先准备环境 系统:Linux(centOS) jdk:1.7 这里jdk要安装配置完成,具体步骤参考:Linux环境下安装JDK 注意:本次没有配置免密登录,所以在启动和停止的时候回让你输入多次 ...

  4. 深入ConcurrentHashMap二

    深入ConcurrentHashMap一,已经介绍了主要的ConcurrentHashMap的结构,Segment组成,HashEntry的组成以及包含ConcurrentHashMap的创建. 这篇 ...

  5. 【prometheus】学习第一篇——prometheus

    前言: 说到监控方案,市面上开源的有很多,最常用的zabbix,深入使用zabbix以后,才知道zabbix设计团队有多厉害,简直是一个完美的监控告警方案.但是在针对docker的监控上还差点,需要自 ...

  6. 有关java之反射的使用

    1 public class Demo02 { 2 @SuppressWarnings("all") 3 public static void main(String[] args ...

  7. 数据库抽象层PDO

    通过数据库抽象层PDO可以访问多个数据库 //数据库抽象层PDO //造DSN:驱动名:dbname=数据库名:host=服务器地址 $dsn = "mysql:dbname=mydb;ho ...

  8. c的详细学习(6)函数

        根据模块化程序设计的原则,一个较大的程序一般要分为若干个小模块,每个模块实现一个比较简单的功能.在c语言中,函数是一个基本的程序模块.     (1)函数的基本概念: 1)基本介绍: 任何一个 ...

  9. CSS3垂直图标菜单

    在线演示 本地下载

  10. CentOS7 + Python3 + Django(rest_framework) + MySQL + nginx + uwsgi 部署 API 开发环境, 记坑篇

    CentOS7 + Python3 + Django(rest_framework) + MySQL + nginx + uwsgi 部署 API 开发环境 CentOS7 + Python3 + D ...