USING GITBASH SHELL SCRIPT Find the even multiples of any number chosen by the user in a given range – the user should specify the multiples of which number they want to print and a minimum and maximum value. The multiples printed should be within the [minimum, maximum] range. For example, if the user choses the number 7 and would like to print all even multiples in the [15, 60] range, the program should print all the even multiples that are bigger than or equal to 15 (minimum), but smaller than or equal to 60 (maximum). The program should keep a count of how many numbers were printed and should output that count, as well as the numbers. The output then, for the example given, should be 28, 42, 56, and the count should be 3.   So l wrote this code as shown by the screenshot and now l want to write the same code using functions this is the code     GNU nano 5.9                                                                                                                       task1.sh #!/bin/bash echo "-----------TASK 1-----------" echo;echo echo " WELCOME!!! " echo;echo #Display to get the user input for number for which multiples are to be found echo "Enter the number to find the multiples:"; #Read the number read number #Display the minimum value of range echo "Enter the minimum value in range:"; #Read the minimum value in range read minimum #Display the maximum value of range echo "Enter the maximum value in range:"; #Read the maximum value in range read maximum #initialize i value to minimum value i=$minimum #initialize index to 0 count=0 #Loop from minimum value to maximum value while [ $i -le $maximum ]  do #Check whether the i value is divisible by number if(( $i % $number == 0)) then if(( $i % 2 ==0 )) then #Check whether the i value is divisible by 2 without remainder. i.e check i is even number result[$count]=$i # If the i value is divisible by the number given and i is even then i is stored in result array ((count++)) fi

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter4: Making Decisions
Section: Chapter Questions
Problem 5PE
icon
Related questions
Question
100%

USING GITBASH SHELL SCRIPT

Find the even multiples of any number chosen by the user in a given range – the user
should specify the multiples of which number they want to print and a minimum and maximum
value. The multiples printed should be within the [minimum, maximum] range. For example, if
the user choses the number 7 and would like to print all even multiples in the [15, 60] range, the
program should print all the even multiples that are bigger than or equal to 15 (minimum), but
smaller than or equal to 60 (maximum). The program should keep a count of how many numbers
were printed and should output that count, as well as the numbers. The output then, for the
example given, should be 28, 42, 56, and the count should be 3.

 

So l wrote this code as shown by the screenshot and now l want to write the same code using functions

this is the code

 

  GNU nano 5.9                                                                                                                       task1.sh
#!/bin/bash
echo "-----------TASK 1-----------"
echo;echo
echo " WELCOME!!! "
echo;echo
#Display to get the user input for number for which multiples are to be found
echo "Enter the number to find the multiples:";

#Read the number
read number

#Display the minimum value of range
echo "Enter the minimum value in range:";

#Read the minimum value in range
read minimum

#Display the maximum value of range
echo "Enter the maximum value in range:";

#Read the maximum value in range
read maximum

#initialize i value to minimum value
i=$minimum

#initialize index to 0
count=0

#Loop from minimum value to maximum value
while [ $i -le $maximum ]
 do
#Check whether the i value is divisible by number
if(( $i % $number == 0))

then
if(( $i % 2 ==0 ))
then

#Check whether the i value is divisible by 2 without remainder. i.e check i is even number
result[$count]=$i
# If the i value is divisible by the number given and i is even then i is stored in result array
((count++))
fi
fi
((i++)) #increment i value by 1
done
#Display the Multiples in the given range
echo "Multiples in given range[$minimum,$maximum] : ${result[@]}"
 #Display the count of multiples in the given range
echo "Count of multiples is $count"
echo;echo
echo "THE END. THANK YOU!!"

 

 

 

 

 

O MINGW64:/c/Users/tafad/week11
GNU nano 5.9
task1.sh
#!/bin/bash
echo "-
echo; echo
echo " WELCOME !!!
echo; echo
#Display to get the user input for number for which multiples are to be found
echo "Enter the number to find the multiples:";
TASK 1-
#Read the number
read number
#Display the minimum value of range
echo "Enter the minimum value in range:";
#Read the minimum value in range
read minimum
#Display the maximum value of range
echo "Enter the maximum value in range:"
#Read the maximum value in range
read maximum
#initialize i value to minimum value
i=$minimum
#initialize index to 0
count=0
#Loop from minimum value to maximum value
while [ $i -le $maximum ]
do
#Check whether the i value is divisible by number
if( $i % $number == 0))
then
if(( $i % 2 ==0 ))
then
#Check whether the i value is divisible by 2 without remainder. i.e check iis even number
result[$count]=$i
# If the i value is divisible by the number given and i is even then i is stored in result array
((count++))I
fi
fi
((i++)) #increment i value by 1
done
#Display the Multiples in the given range
echo "Multiples in given range[$minimum,$maximum] : ${result[@]}"|
#Display the count of multiples in the given range
echo "Count of multiples is $count"
echo; echo
echo "THE END. THANK YOU!!"
AG Help
лх Exit
A0 Write Out
AR Read File
M-] To Bracket
AQ where Was
ЛВ Вack
AF Forward
AW where Is
AK Cut
AC Location
^/ Go To Line
M-U Undo
M-E Redo
M-A Set Mark
М-6 Сору
Ae Prev Word
A. Next Word
AT Execute
M-Q Previous
^\ Replace
AU Paste
AJ Justify
M-W Next
Transcribed Image Text:O MINGW64:/c/Users/tafad/week11 GNU nano 5.9 task1.sh #!/bin/bash echo "- echo; echo echo " WELCOME !!! echo; echo #Display to get the user input for number for which multiples are to be found echo "Enter the number to find the multiples:"; TASK 1- #Read the number read number #Display the minimum value of range echo "Enter the minimum value in range:"; #Read the minimum value in range read minimum #Display the maximum value of range echo "Enter the maximum value in range:" #Read the maximum value in range read maximum #initialize i value to minimum value i=$minimum #initialize index to 0 count=0 #Loop from minimum value to maximum value while [ $i -le $maximum ] do #Check whether the i value is divisible by number if( $i % $number == 0)) then if(( $i % 2 ==0 )) then #Check whether the i value is divisible by 2 without remainder. i.e check iis even number result[$count]=$i # If the i value is divisible by the number given and i is even then i is stored in result array ((count++))I fi fi ((i++)) #increment i value by 1 done #Display the Multiples in the given range echo "Multiples in given range[$minimum,$maximum] : ${result[@]}"| #Display the count of multiples in the given range echo "Count of multiples is $count" echo; echo echo "THE END. THANK YOU!!" AG Help лх Exit A0 Write Out AR Read File M-] To Bracket AQ where Was ЛВ Вack AF Forward AW where Is AK Cut AC Location ^/ Go To Line M-U Undo M-E Redo M-A Set Mark М-6 Сору Ae Prev Word A. Next Word AT Execute M-Q Previous ^\ Replace AU Paste AJ Justify M-W Next
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 8 steps with 5 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,