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 Cosines EmptySat Feb 15, 2014 10:12 am by doriperni

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

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

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

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

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

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

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

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

April 2024
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
282930    

Calendar Calendar


Law Of Cosines

Go down

Law Of Cosines Empty Law Of Cosines

Post by Petahwil Sat Dec 01, 2012 4:54 pm

Moooo Trig!! affraid
Code:

import java.util.Scanner;

/**
 *
 * @author petahwil
 */
public class LawOfCosines {

    /**
    * @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 solving for (a,b,c): ");
        String input = in.next();
        String lower = input;
        String lower2 = "";
        String Upper = "";
        if ("a".equals(input)) {
            lower = "b";
            lower2 = "c";
            Upper = "A";
        }
        else if ("b".equals(input)) {
            lower = "a";
            lower2 = "c";
            Upper = "B";
        }
        else if ("c".equals(input)) {
            lower = "a";
            lower2 = "b";
            Upper = "C";
        }
        else{
            System.out.println("Wrong Format");
            System.exit(1);
        }
        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 " + lower2 + " vaule: ");
        int b = in.nextInt();
       
       
        if ("Rad".equals(mode)){
            double asine = Math.sin(A);
            double equation = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*asine;
            double equ = Math.sqrt(equation);
            System.out.print(input+" = "+equ);
        }
        if ("Deg".equals(mode)){
            double asine = Math.cos(Math.toRadians(A));
            double equation = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*asine;
            double equ = Math.sqrt(equation);
            System.out.print(input+" = "+equ);
        }
       
    }
}

Petahwil

Posts : 8
Join date : 2012-11-30
Age : 31

Back to top Go down

Back to top


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