Using Python to Solve Java Problems | Solving Chapter 1 Exercise 16

123 Просмотры
Издатель
Another programming exercise found in DS Malik's book Java Programming - From Problem Analysis to Program Design 5th Edition, particularly in Chapter 1 Exercise #16.

The Problem
***************
Suppose a, b, and c denote the lengths of the sides of a triangle. Then, the area of the triangle can be calculated using the formula:

square-root of s(s-a)(s-b)(s-c)

where s = (1/2)(a+b+c). Design an algorithm that uses this formula to find the area of a triangle. What information do you need to find the area?

Answer: We need to know the values of a, b, and c.

The Algorithm
*****************
1. Get values of a, b, and c
2. Calculate s by adding a, b, and c and dividing the total by two or
multiplying the total by 0.5
3. Calculate the radicand using the formula:
[s(s-a)(s-b)(s-c)]
4. Apply square root to the radicand to get area of the triangle.
5. Print the area of the triangle.

I hope you will learn from this video. If you have any suggestions, questions, or clarifications, please leave your comments below.

And don't forget to subscribe to get updated with the next videos in this series.

Music Credit: See You On The Otherside - The 126ers
https://www.youtube.com/channel/UCep47rkC_STH4BdGVUTeMnw

#python​ #intermediate #programming #java #computerprogramming
Категория
Язык программирования Java
Комментариев нет.