Question

In: Computer Science

Below, the prompts for the rings’ distances are unclear in terms of which ring is being...

Below, the prompts for the rings’ distances are unclear in terms of which ring is being examined. Rewrite your ring-distance prompt code so that users know which ring the prompt is for. The first two ring-distance prompts should look like this:

Enter ring #1’s distance from the center in cm:

Enter ring #2’s distance from the center in cm

  1. Loop termination by counter method

Write a pseudocode algorithm that analyzes a tree’s annual growth rings. Your algorithm should initially ask the user for the number of annual growth rings that are to be entered. Use a counter loop to ensure that the loop repeats that number of times. Inside the loop, your algorithm should ask the user to enter the distance in centimeters from the tree’s center for each ring, with the smaller ring values entered first. Also inside the loop, your algorithm should calculate the amount of growth that took place for the year associated with the current ring. Below the loop, print the growth for the year where the greatest growth took place.

Solutions

Expert Solution

Thanks for the question.


Here is the Pseudo code for this problem. Comments are included so that you understand whats going on. Let me know if you have any doubts or if you need anything to change.


Thank You !!


========================================================================================

Pseudo Code

// ask user how many rings the tree has
// store it in variable ring_count
ring_count=input('Enter the number of annual growth rings: ')


// this variable will store the largest growth set it to 0
max_growth=0

// this variable will store the year with the largest growth set it to year 1
year_with_largest_growth=1

// will store the previous year growth so that we can find the difference
// between two successive years
distance_from_center=0

// for loop that runs for the number of rings the tree has
for (i=1; i<=ring_count; i++) {

// ask user to enter the distance for the current year
distance=input('Enter ring #{}\'s distance from the center in cm: ',i)

// measure the growth by subtracting previous year distance from current year distance
grown_this_year=distance-distance_from_center
  
  
// store the current year distance to the variable
distance_from_center=distance

// prints the growth for the current year
print('This year the tree has grown {} cm',grown_this_year)


// compare the current year growth with the max growth
// if the current year growth exceeds all time
// then set the current year growth as max growth and year
if grown_this_year>max_growth:
max_growth=grown_this_year
year_with_largest_growth=i

}

// at the end print the max growth and the growth amount
print('The tree has grown maximum on {}th year by {} cms',year_with_largest_growth,max_growth)

=========================================================================================

Python Code to demonstrate the algoirthm works correct.

ring_count=int(input('Enter the number of annual growth rings: '))

max_growth=0
year_with_largest_growth=1
distance_from_center=0
for i in range(1,ring_count+1):
    distance=float(input('Enter ring #{}\'s distance from the center in cm: '.format(i)))
    grown_this_year=distance-distance_from_center
    distance_from_center=distance
    print('This year the tree has grown {} cm'.format(grown_this_year))
    if grown_this_year>max_growth:
        max_growth=grown_this_year
        year_with_largest_growth=i

print('The tree has grown maximum on {}th year by {} cms'.format(year_with_largest_growth,max_growth))

========================================================================================


Related Solutions

A manufacturer produces pistons rings for an automobile engine. It is known that the ring is...
A manufacturer produces pistons rings for an automobile engine. It is known that the ring is approximately normally distributed and has standard deviation of s = 0.001 mm. A random sample of 15 rings has a mean diameter of ?=74.036 x ̅=74.036 mm. (a) Using a level of significance of 0.01, state and test the hypothesis that the mean piston ring diameter is 74.035 mm. (b) What is the minimum level of significance to reject the null hypothesis? c) Use...
A manufacturer produces piston rings for an automobile engine. It is known that the ring diameter...
A manufacturer produces piston rings for an automobile engine. It is known that the ring diameter is normally distributed with σ = 0.001 millimeters. When a random sample of 16 rings is collected, the sample mean of the rings’ diameters is of x- = 74.036 millimeters. a.) In order to find a confidence interval for the true mean piston ring diameter, which distribution table would you use? b.) Find the lower bound of a 95% confidence interval for the mean...
The Chinese Remainder Theorem for Rings. Let R be a ring and I and J be...
The Chinese Remainder Theorem for Rings. Let R be a ring and I and J be ideals in R such that I + J = R. (a) Show that for any r and s in R, the system of equations x ≡ r (mod I) x ≡ s (mod J) has a solution. (b) In addition, prove that any two solutions of the system are congruent modulo I ∩J. (c) Let I and J be ideals in a ring R...
A manufacturer produces piston rings for an automobile engine. It is known that ring diameter is...
A manufacturer produces piston rings for an automobile engine. It is known that ring diameter is Normally Distributed with ? = 0.001 ??. A random sample of 9 rings has a mean diameter of ? = 74.036 ?? a. What is a 95% ?????????? ???????? for the true mean diameter of the piston rings. Use the given ? = 0.001 ??. b. Interpret the ?????????? ???????? constructed in part (a) c. For mathematical purposes, assume for a moment that the...
The Electro-Poly Corporation is the world’s leading manufacturer of slip rings. A slip ring is an...
The Electro-Poly Corporation is the world’s leading manufacturer of slip rings. A slip ring is an electrical coupling device that allows current to pass through a spinning or rotating connection—such as a gun turret on a ship, aircraft, or tank. The company recently received a $750,000 order for various quantities of three types of slip rings. Each slip ring requires a certain amount of time to wire and harness. The following table summarizes the requirements for the three models of...
The Electro-Poly Corporation is the world’s leading manufacturer of slip rings. A slip ring is an...
The Electro-Poly Corporation is the world’s leading manufacturer of slip rings. A slip ring is an electrical coupling device that allows current to pass through a spinning or rotating connection—such as a gun turret on a ship, aircraft, or tank. The company recently received a $750,000 order for various quantities of three types of slip rings. Each slip ring requires a certain amount of time to wire and harness. The following table summarizes the requirements for the three models of...
P4.2.7 Write a script that draws a bullseye with n concentric rings. The kth ring should...
P4.2.7 Write a script that draws a bullseye with n concentric rings. The kth ring should have inner radius k – 1 and outer radius k. (Thus, the innermost ring is just a radius-1 disk.) The kth ring should be colored white if k is odd and red if k is even. This is a matlab problem
A ring of mass 10 kg is being pulled by three ropes, similar to the ring...
A ring of mass 10 kg is being pulled by three ropes, similar to the ring on the force table experiment from your lab class. One rope is pulling with a force of 200 N, the second rope is pulling with a force of 300 N and in a direction that is 98 degrees counterclockwise from the first rope. The third rope is pulling with a force of 400 N and in a direction that is 90 degrees clockwise from...
For the following hypotheses, define each unclear variable in terms of a PRECISE operational definition in...
For the following hypotheses, define each unclear variable in terms of a PRECISE operational definition in terms of objective observations or measures 1. Women are more attracted to men without earrings than men with earrings. Independent Variable- Operational Definition- Dependent Variable- Operational Definition- 2. People learn more when they study in a quiet versus noisy place. Independent Variable- Operational Definition- Dependent Variable- Operational Definition- 3. People who like professional wrestling have poor interpersonal skills. Independent Variable- Operational Definition- Dependent Variable-...
The figure shows two parallel nonconducting rings with their central axes along a common line. Ring...
The figure shows two parallel nonconducting rings with their central axes along a common line. Ring 1 has uniform charge q1 and radius R; ring 2 has uniform charge q2 and the same radius R. The rings are separated by a distance 3.00R. The ratio of the electric field magnitudes of Ring 1 and Ring 2 at point P on the common line is 1.59. What is the ratio of charge magnitudes q1/q2?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT