Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Exercise_1_7 #50

Open
Open
@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 stubSystem.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


      [8]ページ先頭

      ©2009-2025 Movatter.jp