Write a program to compute the area of a triangle using side-angle-side method and reports the area of that triangle (rounded to 2 decimal places).
Side-angle-side formula: ???? = 1/ 2 ?? sin(?), where a and b are two sides of the triangle, and C is the included angle.
Your program must meet the following criteria to receive full marks:
• Randomly generate two values between 5 and 10 (inclusive) for two sides a and b of the triangle, respectively. You must use random module for this (see https://docs.python.org/3/library/random.html?highlight=random#module-random).
• Ask the user for the angle C in degrees (assume user always gives correct input for this one, i.e., a number between 0 and 180, inclusive).
• Python functions require angles in radians. So first convert the degrees value C to radians. You must use Python math module for this (see https://docs.python.org/3/library/math.html).
• Compute the area of the triangle and print the results as follows. You need to use Python math module here (https://docs.python.org/3/library/math.html#trigonometric-functions).
Sample output:
Enter a value for the angle (between 0 to 180): 45
The area of the triangle with a = 7, b = 6 and c = 45 degrees is 14.85
# do comment if any problem arises
# Code
import random
import math
# generate random values for a and b
a=random.randint(5,10)
b=random.randint(5,10)
# read angle from user
c_degrees=int(input("Enter a value for the angle(between 0 to 180): "))
# convert to radians
c_radian=math.radians(c_degrees)
# calculate area
area=1/2*a*b*math.sin(c_radian)
# round to 2 decimal places
area=round(area,2)
print(f'The area of the triangle with a = {a},b = {b} and c = {c_degrees} degrees is {area}')
Screenshot:
Output:
Write a program to compute the area of a triangle using side-angle-side method and reports the...
Write a C++ program to analyze a variety of triangles. The program should determine all angles and all sides for a triangle for three different options (give the user a menu of choices): 1) Given two sides and the angle between 2) Given two angles and one side 3) Given three sides More details for each option is provided below. Option 1: Given two sides and the angle between First check to be sure that the three values entered are...
Problem a (PA4a.java) Write a program to evaluate the area of a triangle given the lengths of its sides using Heron's Formula. Here is an outline: Get the three side lengths from the user (which might have decimal values): a, b, c. Check to ensure that the sides are valid for a triangle. Importantly, the sum of the lengths of any two sides must be larger than the length of the third side (you must check all three sides this...
3. Write a program to calculate the area of a triangle. Your program will take the length of two sides and the included angle (in degrees), then prints the area based on the following formula. A = 1/2 ab sin C
/4 Question An area of square, drea ofa rectangle and triangle can be calculated by using the given formula: sqareaa (renww value from the functioi area is reciabgle-(retrn valwe from the function is area int) ceouatre -D-(return value fromtheneion e s double t and s s formula must be use when the values for the sides of the triangle are whether you want to calculate the area of square or a. b and c are the sides of the triangle...
Use Python WingPersonal to compile and also please give output Math and String operations Write a script to perform various basic math and string operations. Use some functions from Python's math module. Generate formatted output. Basic math and string operations Calculate and print the final value of each variable. a equals 3 to the power of 2.5 b equals 2 b equals b + 3 (use +=) c equals 12 c = c divided by 4 (use /=) d equals...
MATLAB question Triangle Calculations (script with two anon functions) 0 solutions submitted (max: Unlimited) Consider a general triangle with side lengths a, b, and c and angles A, B, and C as shown below Write a script that does the following Define the following two anonymous functions and assign to the indicated Function Handles: 1. The function ThirdSide should accept the lengths of sides a and b as well as angle C in that order and use the Law of...
The "for more practice part" using matlab If the lengths of two sides of a triangle and the angle between them are known, the length of the third side can be calculated. Given the lengths of two sides (b and c) of a triangle, and the angle between them alpha in degrees, the third side a is calculated as follows a^2 = b^2 + c^2 - 2b c cos(alpha) White a script thirdside that will prompt the user and read...
Use Python Write a script to perform various basic math and string operations. Use some functions from Python's math module. Generate formatted output. Basic math and string operations Calculate and print the final value of each variable. a equals 3 to the power of 2.5 b equals 2 b equals b + 3 (use +=) c equals 12 c = c divided by 4 (use /=) d equals the remainder of 5 divided by 3 Built-in functions abs, round, and...
Write a Java program that prompts user to select one of the five shapes(Rectangle, Square, Triangle, Circle, and Parallelogram), then calculate area of the shape,must have input validation and uses more of java library like math class, wrapper class, string methods, use formatted output with the printf method. Finally, create a pseudo-code statement and flowchart
this is a C++ program! You will write a program that performs the following tasks for a simple mathematical calculator: (1) Open a user-specified file for input. Prompt for the name of the file, read it into a string variable, echo print it to the terminal and then open it. If the file is not opened, enter into a loop that prints out an error message, resets the input file stream variable (see the hints section), obtains a new file...