Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify the following Java program so that the equations are written in correct J

ID: 3868959 • Letter: M

Question

Modify the following Java program so that the equations are written in correct Java format. You can use Math.PI as the value of pi public class Equations { public static void main (String[] stuff) { double a 0.5, b = 2.0, c = 3.0, d = 7.0: b = a + 4/4 - c d = (a + b)(a - c) a = 1/b + 1/c + 1/d a = 6.02c + 7.5/bd b = 4/3 pi a^3 d = -b + Squareroot b^2 - 4ac/2a c = tan(c + d)/d + cos(ab) System.out.println("a = "+a+" b = "+b+" c = "+c+" d = "+d): } } When run, the correct answer is: a = -1.3373333333333333 b = -10.018613397481085 c = 1.3986787134935548 d = -7.4714692678265 Differences in the least significant digits are not important.

Explanation / Answer

/* package codechef; // don't place package name! */

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

class Codechef

{

public static void main (String[] args) throws java.lang.Exception

{

// your code goes here

double a=0.5,b=2.0,c=3.0,d=7.0,x=0;

b=(a+4)/(4-c);

d=(a+b)*(a-c);

a=(1/b)+(1/c)+(1/d);

c=1/(b+c+d);

a=6.02*c+(7.5/(b*d));

b=(4*Math.PI*a*a*a)/3;

x= (b*b)-(4*a*c);

d= (-b + Math.sqrt(x))/(2*a);

c=((Math.tan(c+d))/d)+Math.cos(a*b);

System.out.println("a=" +a+ "b=" +b+ "c=" +c+ "d=" +d);

}

}

Output:

a=-1.3373333333333333b=-10.018613397481085c=1.3986787134935548d=-7.4714692678265

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote