Question

Use BASH to run this, Make a code that takes any list of numbers and calculates...

Use BASH to run this,

Make a code that takes any list of numbers and calculates and displays the mean, median and mode.

Homework Answers

Answer #1

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU

read -p "Enter server names separated by 'space' : " -a input

n=${#input[@]}
m=${#input[@]}
sum=0
for i in ${input[@]}
do
   num=${input[`expr $n - 1`]}
   sum=`expr $sum + $num`
   n=`expr $n - 1`
   echo "User entered value :"$i
done
avg=`echo "$sum / $m"|bc -l`
echo "Mean --- "
printf '%0.2f' "$avg"
echo

if (( $m % 2 ==  1 )); then
val="${input[ $(($m/2)) ]}"
else
((j=m/2))
((k=j-1))
((val=(${input[j]} + ${input[k]})/2 ))
fi

echo "median --- "
echo $val
Know the answer?
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
Similar Questions
Create a bash script that takes numbers as parameters, calculates sum and prints the result. If...
Create a bash script that takes numbers as parameters, calculates sum and prints the result. If no parameters passed, prompt a user (only one time) to enter numbers to sum and print the result.
Create a bash script that takes numbers as parameters, calculates sum and prints the result. If...
Create a bash script that takes numbers as parameters, calculates sum and prints the result. If no parameters passed, prompt a user (only one time) to enter numbers to sum and print the result.
Write a python code that calculates the mean and median of a sample of 100 uniform...
Write a python code that calculates the mean and median of a sample of 100 uniform random numbers between 0 and 2 and the percentage of points in the sample that are greater than 1.
In UNIX .Write a bash script that takes a list of usernames as its command line...
In UNIX .Write a bash script that takes a list of usernames as its command line arguments and displays on the screen, for each user name, a message of the form Number of times that logged into this machine is where is to be replaced by the number of recors that the last command output that match exactly. For example, if i enter command logincount mark it should output something like number of times that sweiss logged into this machin...
Write an R code to print out all even numbers from the following numbers list in...
Write an R code to print out all even numbers from the following numbers list in the same order they are received. Write the code so it does not print any numbers that come after 83. numbers = [951, 40, 84, 51, 60, 69, 48, 19, 61, 85, 98, 50, 72, 47, 44, 61, 83, 65, 41, 51, 63, 61, 65, 75, 21, 30, 84, 92, 23]
A delivery truck manager takes a sample of 25 delivery trucks and calculates the sample mean...
A delivery truck manager takes a sample of 25 delivery trucks and calculates the sample mean and sample standard deviation for the cost of operation. A 95% confidence interval for the population mean cost is constructed and found to be $253 to $320. He reasons that this interval contains the mean operating cost for the entire fleet of delivery trucks since the sample mean is contained in this interval. Do you agree with his reasoning? How would you interpret this...
List the numbers here, separated by commas. 96, 80, 91, 83, 40, 98, 86, 91, 72,...
List the numbers here, separated by commas. 96, 80, 91, 83, 40, 98, 86, 91, 72, 60 Calculate the mean, median and mode, showing all your work in step-by-step fashion. Do not use technology for this. Based on your calculations in question 2 above, what can you determine about the shape of the distribution? How do you know this? Calculate the population standard deviation of the data set, again showing all your work in step-by-step fashion. Do not use technology....
Conduct a review of the code of corporate governance of the any MNC. Use the concepts,...
Conduct a review of the code of corporate governance of the any MNC. Use the concepts, tools and techniques to review the structure, process and effectiveness of the governance of the chosen organization and make recommendations for appropriate improvements, if any.
A sequence is a list of numbers that are calculated based on a certain rule. For...
A sequence is a list of numbers that are calculated based on a certain rule. For instance, the progression described by the rule An = 2 ∗ n results in the numbers: 0 2 4 6 8 10 ··· 2 ∗ n. The sum of this sequence can be calculated as Sn = 0+2+4+6+8+10+···+2 ∗ n. Write a function that takes as input the number n and calculates the sum of the sequence up to the nth term (inclusive) for...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter 10 numbers. 2. save those numbers in a 32-bit integer array. 3. Print the array with the same order it was entered. 3. Calculate the sum of the numbers and display it. 4. Calculate the mean of the array and display it. 5. Rotate the members in the array forward one position for 9 times. so the last rotation will display the array in...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT