Dễ 0 đã giải Tỷ lệ chấp nhận 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.

Ràng buộc

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

Ví dụ

Ví dụ 1
Đầu vào:
rate = 5.0
years = 2
principal = 1000.0

Kết quả mong đợi:
expected = 1100.0
Đầu vào:
double rate = 5.0;
long long years = 2;
double principal = 1000.0;

Kết quả mong đợi:
double expected = 1100.0;
Đầu vào:
double rate = 5.0;
long years = 2;
double principal = 1000.0;

Kết quả mong đợi:
double expected = 1100.0;

Giải thích

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

Ví dụ 2
Đầu vào:
rate = 0.0
years = 10
principal = 250.0

Kết quả mong đợi:
expected = 250.0
Đầu vào:
double rate = 0.0;
long long years = 10;
double principal = 250.0;

Kết quả mong đợi:
double expected = 250.0;
Đầu vào:
double rate = 0.0;
long years = 10;
double principal = 250.0;

Kết quả mong đợi:
double expected = 250.0;

Giải thích

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

Tham khảo

Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.

Học hỏi từ người khác

Giải pháp cộng đồng

Chưa có giải pháp nào được chia sẻ. Hãy giải thử thách này để đăng giải pháp đầu tiên.