Question: Use the Bash shell for the completion of this project. Develop a shell scripting application that allows the user to perform some advanced mathematical operations.
Use the Bash shell for the completion of this project.
Develop a shell scripting application that allows the user to perform some advanced mathematical operations.
You application should allow the user to perform these three tasks:
-
Task 1: Find the even multiples of any number the user should specify the multiples of which number they want to print and how many of them (for example if the user choses the number 7 and would like to print four even multiples, the program should print 14, 28, 42, 56 )
-
Task 2: Find the terms of any linear sequence given by the rule Un = an + b, where a and b are integers specified by the user and n is a positive integer, and print them in increasing order (for example if the user inputs a=3, b=4, the first few terms that should be printed are 1, 2, 5, 8, 11...). The user also will specify how many terms the program should print. The user should be allowed to choose another sequence and for the number of terms chosen the program should calculate and print their sum.
-
Task 3: Find the numbers that can be expressed as the product of two nonnegative integers in succession and print them in increasing order. (For example, 30 is such a number as it can be written as the product of 5 and 6 (30=5x6), which are two numbers in succession.) The user should specify a maximum value and the program should print all said numbers smaller than or equal to that value. The program should keep a count of how many numbers were printed and should output that count, as well as the numbers.
Your application should be user friendly. First, you create an initial menu that the user sees when they execute the application. The menu should display the list of operations (the three tasks) that the application can perform.
In your menu design, if user enters M or m, the application should print a list of the multiples of the number (Task 1). The user determines how many numbers they want to see.
If the user enters S or s, the application should print a list of the terms for the chosen sequence (Task 2). The user determines how many terms should be printed.
If the user enters P or p, the program should print a list of the numbers which are products of two numbers in succession (Task 3). The maximum value of the numbers printed should not exceed the value specified by the user.
The program should display the users selection before printing the output. If the user enters a selection which is different from the choices offered, the program should output an error message. After a task has been completed, the user should be given the option to select another task, or to exit.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
