日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

poj 2390 Bank Interest(计算本利和)

發布時間:2023/12/18 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 poj 2390 Bank Interest(计算本利和) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、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(计算本利和)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。