Homework 4.docx - Matthew Schneider CSE 2221(3:00...

This preview shows page 1 - 2 out of 2 pages.

Matthew SchneiderCSE 2221 (3:00)Instructor S. JoshiSeptember 5, 2017Homework 41.privatestaticbooleanpointIsInCircle(doublexCoord, doubleyCoord) {if(Math.sqrt(Math.pow((xCoord - 1), 2))+ Math.pow((yCoord - 1), 2) <= 1) {booleancheck = true;returncheck;} else{returnfalse;}}2.privatestaticintnumberOfPointsInCircle(intn) {intcount = 0;Random rnd = newRandom1L();Random rnd2 = newRandom1L();intnumInCircle = 0;while(count < n) {doublex = 2 * rnd.nextDouble();doubley = 2 * rnd2.nextDouble();booleaninCircle = pointIsInCircle(x, y);if(inCircle == true) {numInCircle++;}count++;}returnnumInCircle;}3.publicstaticvoidmain(String[] args) {/** Open input and output streams*/SimpleReader input = newSimpleReader1L();

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture