Question

Mini Project You are required to do this assignment on your own skills. No copying from...

Mini Project

You are required to do this assignment on your own skills. No copying from other students are not allowed.

Write a menu driven Bash script using the guidelines given below.

Some of the commands and syntax may not be covered in lectures. Please refer other sources to understand syntax and commands you need to complete this assignment.

This program takes user input and to perform simple arithmetic operations such as addition, subtraction, multiplication and division of any two integers.

Part I Script should contain the following tasks:

  1. Script file name: math.sh
  2. Clear the screen.
  3. Enter appropriate comments or descriptions
  4. Ask the user to input a value for each arithmetic calculations; for example, 1 for addition and 2 for subtraction, so on.
  5. Use a case statement condition and the user input, complete arithmetic operations.
  6. Print the result on the screen.

Part II Test your program.

  1. Give proper execute permission to run the script

Part III           Project Submission Information

There are two ways you can submit your mini project.

First option:

  1. Include your screen shot of your script and the output of the script. Output for each operation should be included

Second Option:

  1. Upload your script to the Blackboard

Resources: Lot resources and scripts are available on the Web.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the code to above program

clear
echo "Menu"
echo "1. ADD"
echo "2. SUBSTRACT"
echo "3. MULTIPLY"
echo "4. DIVIDE"
echo "5. EXIT"
echo "Enter your choice: "
read choice
if [ "$choice" -eq 5 ]
then
echo "Exit.."
exit
fi
echo "Enter 1st number: "
read x
echo "Enter 2nd number: "
read y
case $choice in
1) z=$((x+y))
echo "addition is: $z"
;;
2) z=$((x-y))
echo "substraction is: $z"
;;
3) z=$((x*y))
echo "multiplication is: $z"
;;
4) z=$((x/y))
echo "division is: $z"
;;
5) echo "Exit.."
exit
;;
esac

The output of the above code is

Add a comment
Know the answer?
Add Answer to:
Mini Project You are required to do this assignment on your own skills. No copying from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Creating a Calculator Program

    Design a calculator program that will add, subtract, multiply, or divide two numbers input by a user.Your program should contain the following:-The main menu of your program is to continue to prompt the user for an arithmetic choice until the user enters a sentinel value to quit the calculatorprogram.-When the user chooses an arithmetic operation (i.e. addition) the operation is to continue to be performed (i.e. prompting the user for each number, displayingthe result, prompting the user to add two...

  • This is a quick little assignment I have to do, but I missed alot of class...

    This is a quick little assignment I have to do, but I missed alot of class due to the Hurricane and no one here knows what theyre doing. please help! this is Java with intelli-J Overview In this project students will build a four-function one-run calculator on the command line. The program will first prompt the user for two numbers, then display a menu with five operations. It will allow the user to select an option by reading input using...

  • OUTCOMES After you finish this assignment, you will be able to do the following: Define an...

    OUTCOMES After you finish this assignment, you will be able to do the following: Define an abstract class Create concrete classes from an abstract class Overload an operator Split classes into .h and .cpp files Open files for reading Write to files Use output manipulators such as setw, fixed, and setprecision DESCRIPTION A binary arithmetic operation takes two double operands (left and right) to perform addition, subtraction, multiplication, or division on. For example, 10 + 11 is an addition (+)...

  • The assignment In this assignment you will take the Matrix addition and subtraction code and modify...

    The assignment In this assignment you will take the Matrix addition and subtraction code and modify it to utilize the following 1. Looping user input with menus in an AskUserinput function a. User decides which operation to use (add, subtract) on MatrixA and MatrixB b. User decides what scalar to multiply MatrixC by c. User can complete more than one operation or cancel. Please select the matrix operation 1- Matrix Addition A+ B 2-Matrix Subtraction A-B 3Scalar Multiplication sC 4-Cancel...

  • JAVA Problem Description: For this assignment, you will be writing your own exception class and you...

    JAVA Problem Description: For this assignment, you will be writing your own exception class and you will handle run-time exceptions resulting from one particular input situation. Specifics: 1) Design and implement a program that has an exception class called StringTooLongException, designed to be thrown when a string is discovered that has too many characters in it. 2) In the main driver of the program (call this class MyExceptionTest), read strings from the user until the user enters “DONE”. If a...

  • Please do it by C++ programming! By completing this project, you will demonstrate your understanding of:...

    Please do it by C++ programming! By completing this project, you will demonstrate your understanding of: 1) Arithmetic operations (addition, subtraction, multiplication, division, modulus) 2) Conditional statements (If, If-Else, If-ElseIf-Else, Conditional Operator, Switch) 3) Precondition, postcondition, and indexing loops (Do-While, While, For) 4) Standard text file operations (open, close, read, write) 5) Modularizing code by breaking into functions (including functions with input parameters, and ones that return a specific data type) There is a number guessing game similar to MasterMind...

  • Programming Assignment #2 EE 2372 MAKE SURE TO FOLLOW INSTRUCTIONS CAREFULLY, IF YOU HAVE ANY DOUBTS...

    Programming Assignment #2 EE 2372 MAKE SURE TO FOLLOW INSTRUCTIONS CAREFULLY, IF YOU HAVE ANY DOUBTS PLEASE EMAIL ME! This programming assignment will just be a small extension to programming assignment 1. In the first assignment each of the functions could only take a predefined number of inputs. This time the objective is to be able to complete these functions with any amount of inputs. The user will pass arguments through the command line (this means you will have to...

  • Count Occurrences in Seven Integers Using Java Single Dimension Arrays In this assignment, you will design...

    Count Occurrences in Seven Integers Using Java Single Dimension Arrays In this assignment, you will design and code a Java console application that reads in seven integer values and prints out the number of occurrences of each value. The application uses the Java single dimension array construct to implement its functionality. Your program output should look like the sample output provided in the "Count Occurrences in Seven Integers Using Java Single Dimension Arrays Instructions" course file resource. Full instructions for...

  • In this lab you will code a simple calculator. It need not be anything overly fancy,...

    In this lab you will code a simple calculator. It need not be anything overly fancy, but it is up to you to take it as far as you want. You will be creating this program in three small sections. You have the menu, the performance of the basic arithmetic operations (Addition, Subtraction Multiplication, and Division), and the looping. You may want to get the switch menu working first, and then fill in the code for these four arithmetic operations...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT