#!/bin/bash
# Display Product Input Section
echo -e "\nEnter Product 1: Iphone 12"
echo -e "Enter Price: \$75,000.00\n"
echo -e "Enter Product 2: Samsung S21"
echo -e "Enter Price: \$76,000.00\n"
echo -e "Enter Product 3: Xiaomi Black Shark"
echo -e "Enter Price: \$35,000.00\n"
# Predefined Products and Prices
product1="Iphone 12"
price1=75000.00
product2="Samsung S21"
price2=76000.00
product3="Xiaomi Black Shark"
price3=35000.00
# Payment Terms
cash_discount=10
installment_3=5
installment_6=10
installment_12=20
# Display Payment Terms
echo -e "Input Mode of Payment Terms\n"
printf "Cash Discount: %d\n" "$cash_discount"
echo " You input ${cash_discount}% for Cash Discount"
printf "3 Months Installment: %d\n" "$installment_3"
echo " You input ${installment_3}% for 3 Months Installment"
printf "6 Months Installment: %d\n" "$installment_6"
echo " You input ${installment_6}% for 6 Months Installment"
printf "12 Months Installment: %d\n" "$installment_12"
echo " You input ${installment_12}% for 3 Months Installment"
# Main Menu
echo -e "\nMain Menu"
printf "Press I: %-25s %10s\n" "$product1" "\$$(printf "%'.2f" "$price1")"
printf "Press S: %-25s %10s\n" "$product2" "\$$(printf "%'.2f" "$price2")"
printf "Press X: %-25s %10s\n" "$product3" "\$$(printf "%'.2f" "$price3")"
# Automatically Select Item (Iphone 12)
selected_product=$product1
selected_price=$price1
echo -e "\nEnter Item: I"
# Display Selected Product
echo -e "\nYour Item is $selected_product"
printf "Price: %35s\n" "\$$(printf "%'.2f" "$selected_price")"
# Payment Options
echo -e "\nSelect Mode of Payment"
echo "Press 1: Cash - $cash_discount% Discount"
echo "Press 2: 3 Months Installment - $installment_3% Interest"
echo "Press 3: 6 Months Installment - $installment_6% Interest"
echo "Press 4: 12 Months Installment - $installment_12% Interest"
# Automatically Select Payment Mode (3 Months Installment)
payment=2
echo -e "\nEnter Mode of Payment: 2"
# Define Payment Terms
case $payment in
1) discount=$cash_discount; term="Cash";;
2) discount=$installment_3; term="3 Months Installment";;
3) discount=$installment_6; term="6 Months Installment";;
4) discount=$installment_12; term="12 Months Installment";;
esac
# Calculate Total Price
discount_amount=$(echo "$selected_price * $discount / 100" | bc)
if [ "$payment" -eq 1 ]; then
total_amount=$(echo "$selected_price - $discount_amount" | bc)
else
total_amount=$(echo "$selected_price + $discount_amount" | bc)
months=$(echo "$term" | awk '{print $1}') # Extract months from term
monthly=$(echo "$total_amount / $months" | bc)
fi
# Display Final Summary
echo -e "\nMode of Payment: $term"
echo "Item: $selected_product"
printf "Price: %35s\n" "\$$(printf "%'.2f" "$selected_price")"
printf "Discount/Interest: %25s\n" "\$$(printf "%'.2f" "$discount_amount")"
printf "Total Amount: %30s\n" "\$$(printf "%'.2f" "$total_amount")"
if [ "$payment" -ne 1 ]; then
printf "Monthly: %34s\n" "\$$(printf "%'.2f" "$monthly")"
fi