Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 3, Problem 9PE
Program Plan Intro

Area of a triangle

Program Plan:

  • Define the main function.
    • Get the values of “a”, “b”, and “c” from the user.
    • Calculate perimeter of the triangle and store it in a variable “s”.
    • Calculate area of a triangle and store it in a variable “area”.
    • Print the value of “area”.

Blurred answer
Students have asked these similar questions
Using Heron's formula, you can calculate the area of a triangle if you know the lengths of all three sides. Given the length of each side of a triangle as input, calculate the area of the triangle using Heron's formula as follows: s = half of the triangle's perimeter area = the square root of s(s-a)(s-b)(s-c), where a, b, and c are each sides of the triangle. Use the Math.sqrt() method for calculating the square root. Output the floating-point value of the area with three digits after the decimal point, which can be achieved as follows:System.out.printf("The area of the triangle is %.3f\n", yourValue);
You can calculate the area of a triangle if you know the lengths of all three sides, using a formula that has been known for nearly 2000 years. It is called "Heron's Formula". Heron's formula uses the following two steps to calculate the area of a triangle. Step 1: Calculate "s" (half of the triangles perimeter): S= Step 2: Calculate Area: A = √s(sa)(sb)(sc) By using Heron's formula, write the definition of the function area_of_triangle so that it can work in conjunction with the following source code. #include #include int main (void) { double a, b, c, area; printf("Enter the sides of triangle\n"); scanf("%lf%lf%lf", &a, &b, &c); a+b+c 2 area = area_of_triangle (a, b, c); printf ("Area of triangle = %.21f\n", area); return 0; } You can use sqrt() from math.h header file. Its prototype is: double sqrt (double x); A sample run of this program is shown in the following figure. Enter the sides of triangle 4.0 5.0 6.0 Area of triangle = 9.92
The Harris-Benedict equation estimates the number of calories your body needs to maintainyour weight if you do no exercise. This is called your basal metabolic rate, or BMR.The formula for the calories needed for a woman to maintain her weight isBMR = 655 + (4.3 x weight in pounds) + (4.7 x height in inches) -(4.7 x age in years)The formula for the calories needed for a man to maintain his weight isBMR = 66 + (6.3 x weight in pounds) + (12.9 x height in inches) -(6.8 x age in years)A typical chocolate bar will contain around 230 calories. Write a program that allows the userto input his or her weight in pounds, height in inches, age in years, and the character M formale and F for female. The program should then output the number of chocolate bars thatshould be consumed to maintain one's weight for the appropriate sex of the specified weight,height, and age.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY