Algorithm 1: 1. wet hair 2. set value of washCount to 0 3. repeat steps 4 through 6 until the value of washcount equals 2 4. lather hair 5. rinse hair 6. add 1 to the value of washCount 7. stop
Algorithm 2: 1. wet hair 2. lather hair 3. rinse hair 4. lather hair 5. rinse hair 5. stop
Euclid's algorithm: 1. Get two positive integers as input. Call the larger value I and the smaller value J. 2. Divide I by J, and call the remainder R. 3. If R is not 0, then reset I to the value of J, reset J to the value of R, and go back to step 2. 4. Print out the answer, which is the value of J. 5. Stop.a) Go through this algorithm using the input values 20 and 32. After each step of the algorithm is completed, give the values of I, J and R. Determine the final output of the algorithm.
b) Does the algorithm work correctly when the two inputs are 0 and 32? Describe exactly what happens, and modify the algorithm so that it gives an appropriate error message.
a) Read from the user the values for the base and height of a triangle, and print out its area.
b) Read from the user a starting balance and the annual interest rate. Compute (and print) the interest earned in one year assuming simple interest, that is, no compounding. Also determine the final balance at the end of the year.
c) Read from the user the mileage M between them and the average speed of the airplane, and print out the flying time beween two cities.
a) Compute and display the value x/y if the value of y is not 0. Otherwise, display the massage "Unable to perform division!".
b) Compute the area and circumference of a circle given the radius r if the radius is greater than or equal to 1.0. Otherwise you should compute only the circumference.
Enter three numbers: 5 9 2 The largest is 9
Enter a number: 3 Great. Now enter another number: 24 25. I win. Bye!
Enter a number: -10 You are disqualified. Bye!
Enter three numbers: 4 8 3 The numbers in order are: 3 4 8
Note: You may write by hand or use a word processor. If you write by hand, do your best to write legibly. Leave space between problems. Be sure to briefly justify your answers.