Shell Script to Calculate the Loss Percentage of an Article, Given the Cost Price and the Selling Price as Command-Line Arguments

 


Write a shell script to calculate the loss percentage of an article, given the cost price and the selling price as command-line arguments

Code:

echo "Input the cost price of an item"
read cp
echo "Input the selling price of the item"
read sp
if [ $cp -eq $sp ]
then
echo "No Profit or No Gain"

fi
if [ $cp -gt $sp ]
then
s=$((cp - sp))
echo "Loss of Rs:$s"
else
s=$((sp - cp))
echo "Profit of Rs:$s"
fi

Output:



AJ Blogs

Hello everyone, My name Arth and I like to write about what I learn. Follow My Website - https://sites.google.com/view/aj-blogs/home

Post a Comment

Previous Post Next Post
Best Programming Books

Facebook

AJ Facebook
Checkout Our Facebook Page
AJ Blogs
Checkout Our Instagram Page