Saint Louis University |
Computer Science 1300/5001
|
Computer Science Department |
Please make sure you adhere to the policies on academic integrity.
Write a program that asks the user to enter their name and subsequently greets them. The precise format should match the following sample session.
What is your name? Julia
Hello Julia!
(To distingush between the program's output and the user's response, we use underlines to typeset the user's response above, even though no such underlines will appear when executing a script.)
Write a program that prompts the user for the lengths of the two legs of a right triangle, and which reports the length of the hypotenuse. Recall that the hypotenuse length satisfies the formula \(c = \sqrt{a^2 + b^2}\).
Your script should precise adhere to the format demonstrated in the following sample session.
I will compute the hypotenuse of a right triangle. But first, you must tell me the lengths of the legs. What is the length of the first leg? 7 What is the length of the second leg? 4 The length of the hypotenuse is 8.0622577.
(Note: do not worry about the number of decimal digits displayed in the final line. We will learn how to control the appearance of floating-point numbers in output at a later time.)