一、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);}  }     

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

转载于:https://www.cnblogs.com/AndyDai/p/4734141.html

poj 2390 Bank Interest(计算本利和)相关推荐

  1. NUC1373 Bank Interest【水题】

    Bank Interest 时间限制: 1000ms 内存限制: 65535KB 通过次数: 1总提交次数: 1 问题描述 Farmer John made a profit last year! H ...

  2. C语言旅途之用switch计算本利和

    Ⅰ.用switch计算本利和: ①.//代码摘下直接可以运行 #include<stdio.h> int main() { int year; float rate,money,total ...

  3. AcWing 2983. 玩具 / POJ 2318.toys(计算几何基础、二分、判断点和直线的位置关系)

    计算几何基础题 题目大意就是一个盒子被分成了若干个区域,有m个小球,问每个区域里分别有多少个小球. 我们首先考虑暴力. 我们如何判断小球是否在一个区域内呢,我们发现一个小球在区域x,也就是说所有小于x ...

  4. bzoj1755 [Usaco2005 qua]Bank Interest

    题目 深夜水题,利滚利,问最终得到的钱的整数部分. #include<bits/stdc++.h> using namespace std; double r,m,n; int main( ...

  5. POJ 超详细分类

    POJ 各题算法 1000    A+B Problem            送分题     49%    2005-5-7 1001    Exponentiation         高精度   ...

  6. POJ前面的题目算法思路【转】

    1000 A+B Problem 送分题 49% 2005-5-7 1001 Exponentiation 高精度 85% 2005-5-7 1002 487-3279 n/a 90% 2005-5- ...

  7. 怎么用计算机计算复利,如何用普通计算器计算复利

    用普通计算器计算复利: 具体如下: 拿出你的计算器,随便输入一个数字,比如2,然后按一下乘号键,再按一下等号键,是否变成了4?再按一下等号键则变成了8,再按一下等号键--同样输入2,然后按一下除号键, ...

  8. 0317复利计算3.0

    1 package kxj; 2 import java.util.Scanner; 3 4 public class Fulijisuan { 5 public static double p,i, ...

  9. 0330复利计算(修改版)

    1 package kxj; 2 import java.util.Scanner; 3 4 public class Fulijisuan { 5 public static double p,i, ...

最新文章

  1. underscore
  2. centos 7 安装 bzip2 bz2解压使用
  3. c语言 五子棋 悔棋代码,跪求C语言五子棋悔棋部分实现
  4. [软件工程] 查找二维数组最大子数组的之和 郭莉莉李亚文
  5. HDU - 5919 Sequence II
  6. 声纹识别PLDA模型的理解
  7. 数据库周刊第十七期来啦!
  8. 三星w2014android,三星W2014评测:机身细节及内部设计
  9. 数据切分——MySql表分区概述
  10. 如何查看自己在CSDN积分
  11. AMI,HDB3编码译码
  12. 【视频开发】【电子电路技术】监控球机PTZ的功能介绍
  13. 生动的ajax图片显示效果,LightBox
  14. 大学python难不难_“大学四年怎么过?”其实是有答案的
  15. 前端必备知识储存——HTML篇一(面试常考)
  16. 再见 Excel,你好 Python Spreadsheets! ⛵
  17. Flashback 简介
  18. python使用execJS运行js函数例子
  19. UniAPP Android 蓝牙 ESCPOS打印机 打印图片和二维码
  20. sqlyog导入数据的两种方式

热门文章

  1. 五天学习Mysql数据库教程(一)1.1数据库的基本概念
  2. 插入区间Python解法
  3. wifi上行下行速度测试_增大AP天线增益,可以同时改善上下行 —— WIFI基础知识(3)...
  4. 全球服务器系统市场份额,IDC发布2017年第一季度全球融合系统报告 超融合市场最火爆...
  5. android ndk 读短信,Android NDK之发送短信
  6. php redis 读写分离类,yii实现redis读写分离
  7. html表格标签高级应用,asp.net core标签助手的高级用法TagHelper+Form
  8. spring boot 503_Spring实战读书笔记第4章 面向切面的Spring
  9. php后端如何搭建socket服务,从php做一个简单的socket服务器流程
  10. 批量梯度下降python实现_python实现梯度下降算法的实例详解