Course Home | Class Schedule | Moodle CMS | Git Submission | Perusall | Tutoring

Saint Louis University

Computer Science 1300/5001
Introduction to Object-Oriented Programming

Michael Goldwasser

Fall 2019

Computer Science Department

Homework Assignment 02

Please make sure you adhere to the policies on academic integrity.


Problems to be Submitted (20 points)

  1. (10 points)

    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.)

  2. (10 points)

    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.)


Michael Goldwasser
CSCI 1300/5001, Fall 2019
Last modified: Sunday, 22 December 2019
Course Home | Class Schedule | Moodle CMS | Git Submission | Perusall | Tutoring