I need help on computer class... teacher is teaching java and i have to solve a math problem using java codes... i have to make the correct answer of the problem of - "3π sin(187°) + |cos(122°)| [(144.72)to the power of 3.801] + Ln 72" come out on the command prompt after typing "java (name of file)". Ok so how do I make the code to figure this problem out? It would be better if someone just make the code for me.
I know like u start out with like "int a = (something something)" and so on... but whats the rest?
How to make a source code on java to solve math problem?
Well, that's a b-a-s-i-c question that you should work it out yourself; anyway, here is the answer for it, inspect the code carefully and try to do it yourself after understanding it.
public class MathProblem {
public static void main(String[] args) {
double y = 3 *
Math.PI *
Math.sin( Math.toRadians(187) ) +
Math.abs( Math.cos(Math.toRadians(122)) ) *
Math.pow(144.72, 3.801) +
Math.log(72);
System.out.println(
"Y = 3π sin(187°) + |cos(122°)| [(144.72) to the power of 3.801] + Ln 72");
System.out.println(" =" + y);
}
}
Compile the code, run it using java MathProblem, and it should printout the answer on the screen.
Read the documentation (javadoc) of the Math class to get a better idea of all the available math functions.
Good luck...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment