Question: public class Project 1 { public static void main ( String [ ] args ) { / / first problem double problem 1 = 4

public class Project1{
public static void main(String[] args){
//first problem
double problem1=4*(1.0-(1.0/3.0)+(1.0/5.0)-(1.0/7.0)+(1.0/9.0)-(1.0/11.0)+(1.0/13.0)) ;
//second problem
double problem2=4*(1-(1/3)+(1/5)-(1/7)+(1/9)-(1/11)+(1/13)) ;
//print the results
System.out.println("Result of the first problem: "+ problem1);
System.out.println("Result of the second problem: "+ problem2);
//The difference between the two outputs is that in the first problem
//it will give the output in decimal where the second problem the output
//will be rounded up the decimal to its nearest integer value.
//The first problem is the better option because by using the floating
//point division we get the most accurate and precise result where as
//the second output gives a round up result.
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!