Loading…
OS · First scripts · Program 02 · In the record
Write a shell script to print the simple interest of an amount along with total amount
1#!/bin/bash2 3echo "Enter the principal amount:"4read p5 6echo "Enter the rate of interest (% per year):"7read r8 9echo "Enter the time (in years):"10read t11 12si=$(echo "scale=2; $p * $r * $t / 100" | bc)13total=$(echo "scale=2; $p + $si" | bc)14 15echo "Simple Interest = $si"16echo "Total Amount = $total"5000 ⏎ 8 ⏎ 3Enter the principal amount: 5000 Enter the rate of interest (% per year): 8 Enter the time (in years): 3 Simple Interest = 1200.00 Total Amount = 6200.00
Run program 02 in your browser
bash · just-bash. Change the code or the input, run it, break it, and see what happens.