Write a correct, successfully-compiling, correctly-running program to accomplish the items that follow. Here are some pointers to keep in mind for those items:

In your program, you should:

  1. Triangle.java --

    Write code to compute the area of a triangle, whose side lengths are 5.0, 6.0, and 7.0 centimeters. You will need double variables for side a, side b, side c, s, and the triangle's area.

    a, b, c = lengths of sides
    Starting with this formula: s = (a + b + c) / 2
    Triangle area = s(s-a)(s-b)(s-c)

    Use println statements to announce the values of the sides and resulting triangle area (in place of the blank), skipping a line afterward. Use string concatenation with the variables.

    Side A is 5.0 centimeters.
    Side B is 6.0 centimeters.
    Side C is 7.0 centimeters.
    The triangle is _____ square centimeters.

  2. Cylinder.java --

    Write code to compute the surface area of a cylinder, with radius (r) 7cm and height (h) 21cm. You will need variables for the radius, height, and area -- as well as a constant variable for π. Or, in lieu of that, you can use Math.PI -- which you can put in where you would normally put the number.

    Surface area = 2πr2 + 2πrh

    Use println statements to announce the values of the sides and resulting cylinder surface area (in place of the blank), skipping a line afterward. Use string concatenation with the variables.

    Radius is 7.0 centimeters.
    Height is 21.0 centimeters.
    The cylinder's surface area is _____ square centimeters.

  3. QuadraticRoots.java --

    Write code to compute the two roots of a quadratic equation, of the form
    ax2 + bx + c = 0
    whose coefficients a, b, and c are -3, -7, and 5, respectively.

    Root 1 formula:

    -b + b2 - 4ac


             2a

    Root 2 formula:

    -b - b2 - 4ac


             2a

    To do this, you will need variables for a, b, c, the first root, and the second root. Use println statements to announce the values of the coefficients -- and resulting roots, in place of the blanks. Use string concatenation with the variables.

    Coefficient A is -3.0.
    Coefficient B is -7.0.
    Coefficient C is 5.0.
    Root #1 is _____.
    Root #2 is _____.

Program output, when the programs are run, will probably look something like these:

Side A is 5.0 centimeters.
Side B is 6.0 centimeters.
Side C is 7.0 centimeters.
The triangle is _____ square centimeters.




Radius is 7.0 centimeters.
Height is 21.0 centimeters.
The cylinder's surface area is _____ square centimeters.




Coefficient A is -3.0.
Coefficient B is -7.0.
Coefficient C is 5.0.
Root #1 is _____.
Root #2 is _____.
		
Questions:
  1. How did the process of creating these programs go for you?
  2. What were your main challenges and how did you overcome them?
  3. What did you learn that may be of use as you move along in this class?