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:
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 sidesUse 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.
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πrhUse 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.
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
Root 2 formula:
-b - √b2 - 4ac
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 _____.
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: