Java > Array-1 > makePi (CodingBat Solution)

Problem:

Return an int array length 3 containing the first 3 digits of pi, {3, 1, 4}.

makePi() → {3, 1, 4}


Solution:

public int[] makePi() {
  return new int[] {3,1,4};
}



4 comments :

  1. public int[] makePi() {
    int pi[] = {3,1,4};
    return pi;
    }

    ReplyDelete
    Replies
    1. it is wrong because of return type is integer

      Delete
  2. I believe we need to make the pi from 22/7 and catch the first three number in the array. Please correct me.

    ReplyDelete
  3. Math.PI will give the Pi value and we have to extract first 3 digits from there

    ReplyDelete

Follow Me

If you like our content, feel free to follow me to stay updated.

Subscribe

Enter your email address:

We hate spam as much as you do.

Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?

Upload

Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact