Law Of Sine
2 posters
Page 1 of 1
Law Of Sine
Program To Help You With Your Trig!!
- Code:
import java.util.Scanner;
/**
*
* @author petahwil
*/
public class LawOfSines {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner in = new Scanner(System.in);
System.out.print("Enter if you would like the answer in Rad or Deg: ");
String mode = in.next();
boolean check = true;
if ("Rad".equals(mode))
{
check = true;
}
else if ("Deg".equals(mode))
{
check = true;
}
else
{
System.out.println("Wrong Format Input Rad or Deg!");
check = true;
System.exit(1);
}
System.out.print("Enter in what you are using (A,B,C): ");
String upper = in.next();
String lower = upper;
if ("A".equals(upper)) {
lower = "a";
}
else if ("B".equals(upper)) {
lower = "b";
}
else if ("C".equals(upper)) {
lower = "c";
}
else{
System.out.println("Wrong Format");
System.exit(1);
}
System.out.print("Enter what you are solving for (a,b,c): ");
String lower2 = in.next();
String upper2 = lower2;
if ("a".equals(upper2)) {
upper2 = "A";
}
else if ("b".equals(upper2)) {
upper2 = "B";
}
else if ("c".equals(upper2)) {
upper2 = "C";
}
else{
System.out.println("Wrong Format");
System.exit(1);
}
String solve = lower2;
System.out.print("Enter in " + upper + " vaule: ");
int A = in.nextInt();
System.out.print("Enter in " + lower + " vaule: ");
int a = in.nextInt();
System.out.print("Enter in " + upper2 + " vaule: ");
int c = in.nextInt();
if ("Rad".equals(mode)){
double csine = Math.sin(c);
double asine = Math.sin(A);
double equation = (csine*a)/asine;
System.out.print(solve+" = "+equation);
}
if ("Deg".equals(mode)){
double csine = Math.sin(Math.toRadians(c));
double asine = Math.sin(Math.toRadians(A));
double equation = (csine*a)/asine;
System.out.print(solve+" = "+equation);
}
}
}
Last edited by Petahwil on Sun Dec 02, 2012 6:02 pm; edited 2 times in total
Petahwil- Posts : 8
Join date : 2012-11-30
Age : 31
Re: Law Of Sine
ha ha, i wanna post mine to, mine doesn't handle errors xD
- Code:
public static void main(String[] args)
{
// TODO code application logic here
Scanner in = new Scanner(System.in);
System.out.println("Program will imply your input angles in degree");
System.out.print("Enter the first angle: ");
double A = in.nextDouble();
System.out.print("Enter the side opposite with this angle: ");
double a = in.nextDouble();
System.out.print("Enter the second angle: ");
double B = in.nextDouble();
double b = a * Math.sin(Math.toRadians(B)) / Math.sin(Math.toRadians(A));
System.out.println("The length of the side opposite the second angle is " + b);
}
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Sat Feb 15, 2014 10:12 am by doriperni
» Sync2 V2.20.1312 X86x64.rar.rar
Fri Feb 14, 2014 7:37 pm by carmibire
» 9.1 Inheritance Hierarchies
Tue Feb 26, 2013 12:50 pm by ThienDinh
» Useful website
Sat Dec 08, 2012 6:52 pm by tpham1991
» The Machine that Changed the World: Giant Brains. 1992 Documentary
Sat Dec 08, 2012 2:16 am by ThienDinh
» Problems in practice test.
Thu Dec 06, 2012 2:32 pm by ThienDinh
» Newton's Method
Mon Dec 03, 2012 8:32 pm by ThienDinh
» Console Calc
Sun Dec 02, 2012 5:57 pm by Petahwil
» Law Of Cosines
Sat Dec 01, 2012 4:54 pm by Petahwil