asked 21.6k views
1 vote
write the following mathematical expressions in java. t = s_{0} v_{0}*t 1/2 * g * t ^ 2 g = 4pi ^ 2 * (a ^ 3)/(p ^ 2 * (m_{1} m_{2})) fv = pv * (1 (int)/(1% * omega)) ^ (yrs) c = sqrt(a ^ 2 b ^ 2 - 2ab * cos gamma)

asked
User Miran
by
8.0k points

1 Answer

2 votes

Final answer:

To write mathematical expressions in Java, rewrite them using Java's syntax and mathematical functions such as Math.pow for exponents and Math.sqrt for square roots. The provided Java code segments show the conversion of the given expressions into Java-compatible formulas.

Step-by-step explanation:

To write the given mathematical expressions in Java, you need to keep in mind the syntax and mathematical operators used in the Java programming language. Let's break down each expression and rewrite them in Java:



First Expression: t = s0 + v0 * t + 1/2 * g * t2

Java code: double t = s0 + v0 * t + 0.5 * g * Math.pow(t, 2);



Second Expression: g = 4 * Math.PI2 * (a3) / (p2 * (m1 * m2))

Java code: double g = 4 * Math.PI * Math.PI * (Math.pow(a, 3)) / (Math.pow(p, 2) * (m1 * m2));



Third Expression: fv = pv * (1 + (int)/(1% * omega))(yrs)

Java code: double fv = pv * Math.pow(1 + ((int) / (0.01 * omega)), yrs);



Fourth Expression: c = sqrt(a2 + b2 - 2 * a * b * cos(γ))

Java code: double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(gamma));

answered
User Blind Ninja
by
7.6k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.