Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / a script file called mycalc

a script file called mycalc

Computer Science

a script file called mycalc.sh using vim.

 

. It is recommended that your script file is commented throughout the script.

. The script file should perform the following operations: '+' and '-' (addition and subtraction).

 

. The script must have two functions:

a. Each named add and subtract

b. Each of the functions must accept two integer numbers as parameters

c. The functions must perform the desired algebraic operation

 

. The script file should support two modes of operation, either with no parameters or

with three parameters.

a. If three parameters are provided, the second parameter must be + or - :

? The first and third parameters must be numbers.

? The user can enter integer numbers only.

? The result should be displayed on the screen and the program exit.

? The example below demonstrates how the plus operation should work.

 

similar operation for '-'

? Example:

./mycalc 12 + 3

The sum of 12 plus 3 equals 15

 

b. If no parameters are provided the script should do the following:

? A menu should be provided allowing the user to either Exit or

Calculation. Allow upper or lower case menu selections. See Menu 1 below.

Menu 1

 

C) Calculation

X) Exit

 

? If 'C' menu option is selected from Menu 1, the screen should clear and the

user should be prompted to enter a number. See Menu 2 below.

• You don't need to check if the input numbers are integers

 

Menu 2

Please enter an integer number or X to exit:

? If a number is entered into Menu 2, the screen should clear and a new menu

should be displayed. See Menu 3 below.

 

Menu3

+) Add

- ) Subtract

X) Exit

? If + or - is entered the screen should clear and the user should be prompted to

enter a second number. See Menu 2 above.

? If a second number was entered the calculated result should be displayed on

the screen.

? After three seconds the screen should clear and Menu 1 should be displayed

again.

 

c. Error checking should be done to make sure of the following:

? Either no parameters or three parameters are entered.

? If three parameters are entered then the second parameter must be one of

the following + or -.

? Any invalid choices in the menu system should be recognized/identified, and

the user should be presented the menu item again.

? You don't need to check if the input numbers are integers.

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions