CSc 2310 Principles of Computer Programming I
Spring 1999
Programming Assignment #1
Due: 25 January 1999 (Monday)

  1. Write a Java program that reads in the length (in yards) and width (in yards) of a rectangular yard and the length (in yards) and width (in yards) of a rectangular house situated in the yard. Your program should compute the time required (in minutes) to cut the grass at the rate of 2.3 square meters per second. A sample run of the program is shown below:
    [~/teaching/2310/sp99][3:55pm] java p1
    Enter length of yard (in yards): 100
    Enter width of yard (in yards): 100
    Enter length of house (in yards): 30
    Enter width of house (in yards): 30
    Time required to cut the grass is: 55.0 minutes
    
  2. The Pythagorean theorem states that the sum of the squares of the sides of a right triangle is equal to the square of the hypotenuse. For example, if two sides of a right triangle have lengths 3 and 4, then the hypotenuse must have a length of 5. The integers 3, 4, and 5 together form a Pythagorean triple. There are an infinite number of such triples. Given two positive integers, m and n, where tex2html_wrap_inline27 , a pythagorean triple can be generated by the following formulas:

    tex2html_wrap_inline29
    tex2html_wrap_inline31
    tex2html_wrap_inline33

    Write a Java program that reads in values for m and n and prints the values of the Pythagorean triple generated by these formulas. A sample run of the program is shown below:

    [~/teaching/2310/sp99][11:48am] java p2
    Enter values of m: 6
    Enter values of n: 4
    The pythogorean triple generated by  6 and 4 is 20, 48, and 52

Raj Sunderraman
Wed Jan 13 14:01:59 EST 1999