Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

RECITATION DESCRIPTION: The purpose of this laboratory assignment is to get you further practice in writing bash scripts. You may use other resources for this

image text in transcribed
image text in transcribed
image text in transcribed
RECITATION DESCRIPTION: The purpose of this laboratory assignment is to get you further practice in writing bash scripts. You may use other resources for this exercise including scripts in my public directory (cd mat0299/public/csce3600/sp19/), the lecture notes on Caivas, ection 9.2 Shell Scripting in the textbook, or searching for "bach tutorial" on Googe, for example. Please feel free to also ask for assistance from your TA or fellow mates, but make sure that you turn in your own work. Please note that you are class writing a bash script, not a C program, for this exercise. Write a bash script called rec05.sh that curves the quiz grades using for loops, 1. Write a function called curve that will apply a given curve to an array of grades. a. Assign the first positional parameter sent to the function to a user-defined arrays, and functions as follows: This function will take as input the curve amount, followed by the array of grades. variable called incr. b. Use the shift com mand with no arguments that will shift all arguments to the left (that means the first positional parameter will disappear, but that's oK because we already assigned it to incr). The rest of the parameters represent elements in the array passed to the function. c. Now, assign the rest of the elements of the array to arr using ("e"). See feb13N.sh from my public directory for help on this and other parts of this recitation. d. Create a new user variable called index and assign the value 0. e. Write a traditional for loop that uses the control variable i to iterate over the elements of the array, as in "(arr [e]". Inside the for loop, you will have two lines: i. Use let to assign the sum of the control variable i and the value of incr to the array rades with subscript index the array grades with subscript index. ii. Then, increment the value of index by 1 2. Your program should accept 1 command-line argument: the amount that grades will be curved in this script. If the number of positional parameters is not equal to 1 (meaning that nothing was passed in as a command-line argument), then you will print out a usage statement indicating that the curve amount should be passed in as a command-line argument. Otherwise, you will do the following: a. Vrite a traditional bash for loop that iterates over the arguments 1,2, 3, 3. anc 5. Inside the for loop, you will prompt for the user to enter their grade for a numbered quiz (see SAMPLE OUTPUT) and store that value into an array called grades using the read command. When indexing into the array, be sure to use $i-1, assuming i is the control variable of the for loop. Call the curve function, passing in the first positional parameter (i.e., the amount of the curve) and the array grades itself. The array can be passed using "$igrades [@]) ". b. c. Use echo to print out the message "Curved Grades:". d. Now, use a C-like for loop to iterate through all elements of the grades array and print out the text for the atrav element (see SAMPLE OUTPUT) along with grades using the read command. When indexing into the array, be sure to use $i-1, assuming i is the control variable of the for loop. b. Call the curve function, passing in the first positional parameter (i.e., the amount of the curve) and the array grades itself. The array can be passed using "$Igrades [@])". c. Use echo to print out the message "Curved Grades: ". d Now, use a C-like for loop to iterate through all elements of the grades array and print out the text for the array element (see SAMPLE OUTPUT) along wit the value of the now curved grade. Take a look at the bash lecture notes or the example feb13N.sh for details on how to do this. SAMPLE OUTPUT (input in bold): s/rec05.sh usage: /rec05.sh s /reco5.sh 5 Enter QUIZ #1: 92 Enter QUIZ #2: 84 Enter QUIZ #3: 75 Enter QUIZ #4: 88 Enter QUIZ #5: 96 Curved Grades: grades [0]97 grades [1] 89 grades [280 grades [3] 93 grades [4]101 REQUIREMENTS: No comments are required for this recitation assignment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions