Skip to content

Exercise_1_7 #50

@aplusdesigners

Description

@aplusdesigners

I am not sure if it is an issue with the Java version I am coding on, an Eclipse issue or code issue. When I run the code in Exercise_1_7, it outputs 4.0 as both outputs. I have to change all instances of 1 to 1.0 in the fractions, like this:

`public class Exercise_1_7 {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	System.out.println(4 * ( 1.0 - (1.0 / 3) + (1.0 / 5) - (1.0 / 7) + (1.0 / 9) - (1.0 / 11)));
	System.out.println(4 * ( 1.0 - (1.0 / 3) + (1.0 / 5) - (1.0 / 7) + (1.0 / 9) - (1.0 / 11) + (1.0 / 13)));
}

}`

My output is:
2.9760461760461765
3.2837384837384844

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions