write a script named compute.sh that is used to do simple arithmetic for the user. There...

50.1K

Verified Solution

Question

Programming

write a script named compute.sh that is used to do simplearithmetic for the user. There should be no command line arguments.Instead, all values from the user should be prompted for and readin to the script using the read command.Specifically, you need to ask the user for two integers and anoperation string. The operation should be \"add\", \"sub\",\"mul\", \"div\", or \"exp\", for addition, subtraction,multiplication, division, and exponentiation, respectively. Yourscript should take the two numbers, perform the requestedoperation, and output the result. Here is a sample run:

[user@localhost ~]$ compute.sh

Enter an integer: 5

Enter another integer: 7

Enter an operation (add,sub,mul,div,exp):mul

5 * 7 = 35

[user@localhost ~]$

The script will have to translate the operation string to thecorrect operation using either a case statement or if/elsestatements. Note that you do not need to verify that the numbersgiven are actual numbers, but you DO need to verify that theoperation string is one of the five listed operations. If it isn'tone of the five, print an appropriate error message and exit.

Be sure to test your script thoroughly. When you're done,TAKE A SCREENSHOT (5) of the output of the scriptusing some example inputs.

TAKE A SCREENSHOT (6 – computer.sh) yourscript. I can’t grade if your screenshot is not readable. Biggerfont please! If you can’t control font size, please submit the fileas text format.

Answer & Explanation Solved by verified expert
3.6 Ratings (397 Votes)
echo Enter an integer read number1echo Enter an integer read number2echo Enter an operation    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students