A Bash script that calculates simple interest from a principal amount, an annual interest rate, and a time period in years.
- Interactive prompts for principal, annual rate (in percent), and time period in years
- Computes simple interest as
principal × time × rate / 100 - Single self-contained script with no dependencies beyond a POSIX shell with
expr
bash simple-interest.shExample session:
Enter the principal:
1000
Enter rate of interest per year:
5
Enter time period in years:
2
The simple interest is:
100
- The script uses
expr, which only does integer arithmetic, so enter whole numbers. - No input validation is performed.
- Sample code for learning purposes. Do not use it in production.
- Original author: Upkar Lidder (IBM), per the script header
- Additional author: y0c0ms
Apache License 2.0. See LICENSE.
© 2023 XYZ, Inc.