Java Reference
In-Depth Information
The following program solves right triangles by means of Pythagoras'
theorem and by applying the side/angle formula.
// Java for Engineers
// Filename: TrigSolv
// Reference: Chapter 24
// Description:
//
Solving right triangles
// Requires:
//
Keyin class in current directory
import java.lang.*;
strictfp class TrigSolv
{
public static void main(String[] args)
{
double a, b, c, angleA, radA;
// Pythagoras' Theorem
// Obtain sides from user
System.out.println(“Side c in terms of sides a and b”);
a = Keyin.inDouble(“Enter side a: ”);
b = Keyin.inDouble(“Enter side b: ”);
c = Math.sqrt((a * a)+(b * b));
System.out.println(“Sidec=”+c);
// Side-angle formula
System.out.println(“Side c in terms of side b and angle A”);
b = Keyin.inDouble(“Enter side b: ”);
angleA = Keyin.inDouble(“Enter angle A: ”);
radA = Math.toRadians(angleA);
c=b*Math.tan(radA);
System.out.println(“Sidec=”+c);
}
}
On the Web
The program named TrigSolv.java is found in the Chapter 24 folder at
www.crcpress.com .
Solving Quadratic Equations
The general quadratic equation is expressed by the formula:
Search WWH ::




Custom Search