簡単 0件解決済み 正答率0%

Simple Interest

Find the total amount after simple interest.

問題

Money in a savings account earns simple interest: each year adds rate percent of the original amount principal. Compute the total balance after years years.

Implement simple_interest_total(principal, rate, years).

Input

principal: The starting amount. rate: The yearly interest rate in percent. years: The number of whole years.

Output

Return principal + principal × rate / 100 × years.

制約

0 ≤ principal ≤ 1,000,000; 0 ≤ rate ≤ 100; 0 ≤ years ≤ 100

例

例 1
入力:
rate = 5.0
years = 2
principal = 1000.0

期待される出力:
expected = 1100.0
入力:
double rate = 5.0;
long long years = 2;
double principal = 1000.0;

期待される出力:
double expected = 1100.0;
入力:
double rate = 5.0;
long years = 2;
double principal = 1000.0;

期待される出力:
double expected = 1100.0;

解説

Each year earns 1000 × 5% = 50, so two years add 100: 1000 + 100 = 1100.

例 2
入力:
rate = 0.0
years = 10
principal = 250.0

期待される出力:
expected = 250.0
入力:
double rate = 0.0;
long long years = 10;
double principal = 250.0;

期待される出力:
double expected = 250.0;
入力:
double rate = 0.0;
long years = 10;
double principal = 250.0;

期待される出力:
double expected = 250.0;

解説

With a 0% rate nothing is added, so the balance stays 250.

参考資料

この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。

他の人の解答から学ぶ

コミュニティの解答

まだ公開された解答がありません。この課題を解いて最初の解答を共有しましょう。