Question

In: Computer Science

Here is a script created a few years back. It has a few issues. See if...

Here is a script created a few years back. It has a few issues. See if you can make it work.

#!/bin/bash

# created by Your Name

# date

quit=no

while [ $quit = no ]

do

cat <<++

        1) Roll Again?

        2) Quit

++

# code to roll dice

read selection

case $selection in

        1)

          echo “Enter a number between 1 and 10”

          read repeats

          let seed=0

          let r=0

          while [ $r -le $repeats ]

          do

                        let seed=7621*$seed+1

                        let n=5*$seed/10000000+1

                        let r=$r+1

          done

          echo $n

        ;;

        2)

          quit=yes

        ;;

esac

done

Solutions

Expert Solution

Answer: I ran the same code without any issues, please leave a comment if it doesn't work for you. I have put some echo statements to print the values. Hope this helps, good luck!

Output:

Code:

#!/bin/bash

# created by Your Name
# date

quit=no
while [ $quit = no ]
do
cat <<++

1) Roll Again?
2) Quit
++

# code to roll dice

read selection
case $selection in

1)

echo 'Enter a number between 1 and 10'
read repeats
let seed=0
let r=0

while [ $r -le $repeats ]
do

#!/bin/bash

# created by Your Name
# date

quit=no
while [ $quit = no ]
do
cat <<++

1) Roll Again?
2) Quit
++

# code to roll dice

read selection
case $selection in

1)

echo 'Enter a number between 1 and 10'
read repeats
let seed=0
let r=0

while [ $r -le $repeats ]
do

let seed=7621*$seed+1
echo "The seed : $seed"
let n=5*$seed/10000000+1
echo "The value of n : $n"
let r=$r+1
echo "The value of r : $r"

done
echo $n
;;

2)
quit=yes
;;
esac
done

let seed=7621*$seed+1
echo "The seed : $seed"
let n=5*$seed/10000000+1
echo "The value of n : $n"
let r=$r+1
echo "The value of r : $r"

done
echo $n
;;

2)
quit=yes
;;
esac
done


Related Solutions

“Dollar Shave Club” created an ad for their services that went viral a few years back....
“Dollar Shave Club” created an ad for their services that went viral a few years back. On the strength of the ad alone they were able to attract over 200,000 subscribers. What does the “Dollar Shave Club” do…? They provide inexpensive razor blades that they deliver each month. There are three pricing options ($3.50, $6.50, and $9.50 per month including shipping). First, explain how they have segmented the market. Which key needs have they targeted? How would you go about...
Bill moved in with his mother a few years back. She is now thinking that this...
Bill moved in with his mother a few years back. She is now thinking that this was a bad idea so she has promised to give him $10,000 when he leaves the house forever toward the downpayment on a new home. Bill had planned to leave in five year time. However, the offer from his mother has him thinking that he could leave one year earlier than he had planned. As a result, the present value of this offer will:...
A few years back, Dave and Jana bought a new home. They borrowed $230,415 at an...
A few years back, Dave and Jana bought a new home. They borrowed $230,415 at an annual fixed rate of 5.49% (15-year term) with monthly payments of $1,881.46. They just made their 40th payment, and the current balance on the loan is $208,555.87. Interest rates are at an all-time low, and Dave and Jana are thinking of refinancing to a new 15-year fixed loan. Their bank has made the following offer: 15-year term, 3.0%, plus out-of-pocket costs of $2,937. The...
A few years back, Dave and Jana bought a new home. They borrowed $230,415 at an...
A few years back, Dave and Jana bought a new home. They borrowed $230,415 at an annual fixed rate of 5.49% (15-year term) with monthly payments of $1,881.46. They just made their 25th payment, and the current balance on the loan is $208,555.87. Interest rates are at an all-time low, and Dave and Jana are thinking of refinancing to a new 15-year fixed loan. Their bank has made the following offer: 15-year term, 3.0%, plus out-of-pocket costs of $2,937. The...
A few years back, Dave and Jana bought a new home. They borrowed $230,415 at an...
A few years back, Dave and Jana bought a new home. They borrowed $230,415 at an annual fixed rate of 5.49% (15-year term) with monthly payments of $1,881.46. They just made their 50th payment, and the current balance on the loan is $208,555.87. Interest rates are at an all-time low, and Dave and Jana are thinking of refinancing to a new 15-year fixed loan. Their bank has made the following offer: 15-year term, 3.0%, plus out-of-pocket costs of $2,937. The...
A few years back, Dave and Jana bought a new home. They borrowed $230,415 at an...
A few years back, Dave and Jana bought a new home. They borrowed $230,415 at an annual fixed rate of 5.49% (15-year term) with monthly payments of $1,881.46. They just made their 50th payment, and the current balance on the loan is $208,555.87. Interest rates are at an all-time low, and Dave and Jana are thinking of refinancing to a new 15-year fixed loan. Their bank has made the following offer: 15-year term, 3.0%, plus out-of-pocket costs of $2,937. The...
What are a few companies that made headlines in recent years for major issues they have...
What are a few companies that made headlines in recent years for major issues they have faced in terms of their company status, decisions( decision-making over time, profit maximization, cost minimization, long-run adjustments, strategic interaction, etc.) Then, describe the firm you have identified, including a report concerning what they produce and what market they are in. Provide some analysis of the structure of that market
Assignment Description: In this assignment, a script file should be created to contain a set a...
Assignment Description: In this assignment, a script file should be created to contain a set a SQL statements for the Pretty Prints Company to better manage their business. Use the database created for Pretty Prints in Assignment 2. Include the SQL statements to satisfy the following queries. The following queries should be included in the script: Create a view named Under_100. It consists of the item_id, title, artist, unit_price and order_qty for every print with a unit_price under 100 dollars....
I am writing a matlab program where I created a figure that has a few different...
I am writing a matlab program where I created a figure that has a few different elements to it and now I need to move that figure into a specific excel file into a specific set of boxes in the excel file. With numbers and text I have always used the xlswrite function for this in order to put data into specific boxes. How do I do the same with this figure? The figure I have is called like this:...
​As you can see in the following table, demand for heart transplant surgery at Washington General Hospital has increased steadily in the past few years
As you can see in the following table, demand for heart transplant surgery at Washington General Hospital has increased steadily in the past few years: Year12345Heart Transplants48.052.053.057.057.0The director of medical services predicted 6 years ago that demand in year 1 would be 44.0 surgeries.a) Using exponential smoothing with a of 0.60 and the given forecast for year 1, the forecasts for years 2 through 6 are (round your responses to one decimal place): Year123456Forecast44.046.449.851.754.956.2For the forecast made using exponential smoothing with a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT