Question

In: Computer Science

Open the terminal and using vi/vim create a new script and name it lab6 Insert at...

  • Open the terminal and using vi/vim create a new script and name it lab6
  • Insert at the top of your file a comment with your name, class and section number (e.g. #John Doe, EMT 2390L - OL123).
  • In this lab you are going to display a multiplication table of a number entered by the user between 2 and 10 using a for loop and without using multiplication. The table will display the values that are less than or equal to 100.
  • Ask the user what multiplication table to display and save that value in a variable named table.
  • Validate the value of the variable table so that it is a number between 2 and 10 inclusive.
  • Using a for loop, display the values of the multiplication table of the number entered by the user in the variable table, going up to 100.
  • Save the script and make it executable (HINT: use the chmod command with mode 755).
  • Execute the script (HINT: use dot slash ./ combination, followed by your script name) and fix any errors.
  • Submit here on Blackboard your script file. DO NOT submit screen shots, ZIP files, or any other kind of file. Submission is on Blackboard ONLY. DO NOT send emails or messages, use the Blackboard link to the lab in order to submit.
  • Deadline: 10/28 at 11:59PM

Solutions

Expert Solution

Hi,

/*

NOTE: I hope in this question you need a shell script for the multiplication table till 100 between 2 and 10 inclusive.

I am assuming that you can open the terminal and create a new_script.sh using vim command and put your name, and other things asked. If there is any problem you face on this, kindly revert back to me.

For your shell script code is given below you can add this to your new_script file.

*/

Code:

#reading the number
echo "Enter a Number"
read n

# Checking for the condition

if (( $n<2 || $n>10 ))
then
#If they are not between 2 and 10 inclusive then print this
echo "Please input the values between 2 and 10 inclusive."
else

# printing the multiplication table for input value upto 100;
i=1
while [ $i -le 100 ]
do
   echo " $n x $i = `expr $n \* $i`"
   i=`expr $i + 1`
done
fi

Input and ouput with code snippet is attached below.

Firstly,

In terminal, write

chmod +x <YOUR_SCRIPT_NAME>

then excecute

./<YOUR_SCRIPT_NAME>

.

.

.

.

.

.

.

.

.

Thanks


Related Solutions

Use Vi text editor or ATOM to create a bash script file. Use the file name...
Use Vi text editor or ATOM to create a bash script file. Use the file name ayaan.sh. The script when ran it will execute the following commands all at once as script. Test your script file make sure it works. Here is the list of actions the script will do: It will create the following directory structure data2/new2/mondaynews off your home directory. inside the mondaynews, create 4 files sports.txt, baseball.txt, file1.txt and file2.txt. Make sure file1.txt and file2.txt are hidden...
I am using a Macbook and trying to use the terminal and a VIM editor to...
I am using a Macbook and trying to use the terminal and a VIM editor to create program. This program will allow you to enter the costs of each ingredient and product, then prompt for the amount of each ingredient bought (individually by ingredient) and product sold (also individually), and from there show profit or loss, as well as profit on average for each unit sold. There will be say, 2 ingredients to buy and 3 products to sell. Please...
Task: 2.1 : Shell Scripting Task1 :Traditional hello world script Open terminal create Lab01 directory and...
Task: 2.1 : Shell Scripting Task1 :Traditional hello world script Open terminal create Lab01 directory and use cd command to move into the directory Open a new file script hello.sh using vi editor # vi hello.sh Type the following lines #!/bin/bash           echo Hello World     Save the file and return back to terminal How to Runhello.sh Adding Execute Permission Checking current permission        # ls -la hello.sh Adding Execute permission # chmod u+x hello.sh   Check whether execute permission is added # ls...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform a ls -al on the files within the user's home directory and save it to a file called ls.dat within your ~ directory 2.   Save the tree information for the /home directory in a file called tree.dat within your ~directory 3.   Create a new directory in your home directory called "backups" 4.   Move the files you just created to the new directory 5.   Rename...
My code does not compile, I am using vim on terminal and got several compiling errors...
My code does not compile, I am using vim on terminal and got several compiling errors this is C++ language I need help fixing my code below is the example expected run and my code. Example run (User inputs are highlighted): Enter your monthly salary: 5000 Enter number of months you worked in the past year: 10 Enter the cost of the car: 36000 Enter number of cars you’ve sold in the past year: 30 Enter number of misconducts observed...
Create a basic VI by using labVIEW software. Kindly share screenshot of basic VI
Create a basic VI by using labVIEW software. Kindly share screenshot of basic VI
QUESTION 5 1.    Switch to insert mode, and then create a script that performs the following: •       Sets...
QUESTION 5 1.    Switch to insert mode, and then create a script that performs the following: •       Sets the environment for the script to bash •       Have at least two comment lines that state the purpose of the script •       Clear the screen •       Sends messages back to the screen informing the user of what he or she is seeing displayed on the screen •       Have the script perform the following: o   Show your home directory o   Show your current working directory o   Create a directory called demo, and...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and save all your files for this lab into this new folder. 2. You can use any IDE (such as SciTE, NetBeans or Eclipse) or any online site (such as repl.it or onlinegdb.com) to develop your Java programs 3. All your programs must have good internal documentation. For information on internal documentation, refer to the lab guide. Problems [30 marks] Problem 1: The Account class...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and save all your files for this lab into this new folder. 2. You can use any IDE (such as SciTE, NetBeans or Eclipse) or any online site (such as repl.it or onlinegdb.com) to develop your Java programs 3. All your programs must have good internal documentation. For information on internal documentation, refer to the lab guide. Problem : The Fraction class (Filename: TestFraction.java) Design...
Using Python The script is to open a given file. The user is to be asked...
Using Python The script is to open a given file. The user is to be asked what the name of the file is. The script will then open the file for processing and when done, close that file. The script will produce an output file based on the name of the input file. The output file will have the same name as the input file except that it will begin with "Analysis-". This file will be opened and closed by...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT