#!/bin/bash
# Read input
read item
read payment_mode
# Assign item name and price
case $item in
1) item_name="Iphone 12"; price=75000 ;;
2) item_name="Samsung S21"; price=76000 ;;
3) item_name="Xiaomi Black Shark"; price=35000 ;;
*) echo "Invalid item"; exit 1 ;;
esac
# Assign payment mode, discount/interest, and months
case $payment_mode in
1) discount=10; months=0 ;;
2) discount=-5; months=3 ;;
3) discount=-10; months=6 ;;
4) discount=-20; months=12 ;;
*) echo "Invalid payment mode"; exit 1 ;;
esac
total_price=$(( price + (price * discount / 100) ))
monthly_payment=$(( total_price / (months > 0 ? months : 1) ))
# Output
echo "Item: $item_name"
echo "Price: \$$price.00"
echo "Discount/Interest: ${discount}%"
echo "Total Amount: \$$total_price.00"
if [[ $months -gt 0 ]]; then
echo "Monthly: \$$monthly_payment.00"
fi
IyEvYmluL2Jhc2gKCiMgUmVhZCBpbnB1dApyZWFkIGl0ZW0gCnJlYWQgcGF5bWVudF9tb2RlCgojIEFzc2lnbiBpdGVtIG5hbWUgYW5kIHByaWNlCmNhc2UgJGl0ZW0gaW4KICAgIDEpIGl0ZW1fbmFtZT0iSXBob25lIDEyIjsgcHJpY2U9NzUwMDAgOzsKICAgIDIpIGl0ZW1fbmFtZT0iU2Ftc3VuZyBTMjEiOyBwcmljZT03NjAwMCA7OwogICAgMykgaXRlbV9uYW1lPSJYaWFvbWkgQmxhY2sgU2hhcmsiOyBwcmljZT0zNTAwMCA7OwogICAgKikgZWNobyAiSW52YWxpZCBpdGVtIjsgZXhpdCAxIDs7CmVzYWMKCiMgQXNzaWduIHBheW1lbnQgbW9kZSwgZGlzY291bnQvaW50ZXJlc3QsIGFuZCBtb250aHMKY2FzZSAkcGF5bWVudF9tb2RlIGluCiAgICAxKSBkaXNjb3VudD0xMDsgbW9udGhzPTAgOzsKICAgIDIpIGRpc2NvdW50PS01OyBtb250aHM9MyA7OwogICAgMykgZGlzY291bnQ9LTEwOyBtb250aHM9NiA7OwogICAgNCkgZGlzY291bnQ9LTIwOyBtb250aHM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