Computer Science
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

Keywords

Latest topics
» (2011Q2) ??????? ?????? ?41? ???????????!/????????????!?(TX 1280x720 X264 AAC).mp4
Law Of Sine EmptySat Feb 15, 2014 10:12 am by doriperni

» Sync2 V2.20.1312 X86x64.rar.rar
Law Of Sine EmptyFri Feb 14, 2014 7:37 pm by carmibire

» 9.1 Inheritance Hierarchies
Law Of Sine EmptyTue Feb 26, 2013 12:50 pm by ThienDinh

» Useful website
Law Of Sine EmptySat Dec 08, 2012 6:52 pm by tpham1991

» The Machine that Changed the World: Giant Brains. 1992 Documentary
Law Of Sine EmptySat Dec 08, 2012 2:16 am by ThienDinh

» Problems in practice test.
Law Of Sine EmptyThu Dec 06, 2012 2:32 pm by ThienDinh

» Newton's Method
Law Of Sine EmptyMon Dec 03, 2012 8:32 pm by ThienDinh

» Console Calc
Law Of Sine EmptySun Dec 02, 2012 5:57 pm by Petahwil

» Law Of Cosines
Law Of Sine EmptySat Dec 01, 2012 4:54 pm by Petahwil

April 2024
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
282930    

Calendar Calendar


Law Of Sine

2 posters

Go down

Law Of Sine Empty Law Of Sine

Post by Petahwil Sat Dec 01, 2012 3:12 pm

Program To Help You With Your Trig!! bounce bounce bounce
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

Back to top Go down

Law Of Sine Empty Re: Law Of Sine

Post by ThienDinh Sat Dec 01, 2012 3:16 pm

ha ha, i wanna post mine to, mine doesn't handle errors xD study
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);       
    }

ThienDinh
Admin

Posts : 27
Join date : 2012-11-30

https://computerscienceqc.board-directory.net

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum