Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
763 B
1
Indexable
Never
#!/bin/bash

read -p "How many calculations do you wish to do? " num_calcs

for (( i=1; i<=$num_calcs; i++ ))
do
    read -p "Enter the first number: " num1
    read -p "Enter the second number: " num2
    
    echo "What operation do you want to perform?"
    echo "1. Addition"
    echo "2. Subtraction"
    read -p "Enter your choice (1 or 2): " choice

    case $choice in
        1)
            result=$((num1+num2))
            echo "The sum of $num1 and $num2 is $result"
            ;;
        2)
            result=$((num1-num2))
            echo "The difference between $num1 and $num2 is $result"
            ;;
        *)
            echo "Invalid choice. Please enter 1 or 2."
            ;;
    esac
    
    echo
done