please send edited code I have posted this a few times with
please send edited code. I have posted this a few times with lots of incorrect feedback.
Main.java
package part2;
import java.util.Random;
public class Main {
static final int NUM = 10;
public static void main(String[] args) {
EZ.initialize(600, 600);
Data [] datapoints = new Data[NUM];
Random rg = new Random();
for (int i=0; i<NUM; i++) {
datapoints[i] = new Data(rg.nextInt(600), rg.nextInt(600));
}
for (int i=0; i<NUM; i++) {
datapoints[i].draw();
}
Data.drawCenter();
Data.print();
}
}
Data.java
package part2;
import java.awt.Color;
public class Data {
// static variables
// member variables
// static functions
public static void print() {
}
public static void drawCenter() {
}
// member functions
public Data(int _x, int _y) {
}
public void draw() {
}
}
Part 2- Static In the attached project, look at part 2. You need to complete the Data class (and you can use Main to test it). Every time we create a new Data object, our static variables will keep track of the number of data points and what is their average center point. In Data.iava 1. Add 3 static variables: an integer called count, and floats called centerX and centerY (their initial value should be 0) Add 2 member variables: integers called x and y Make the static function print0 print out how many data points there are and what is the center point For example: There are 10 data points Centered at (360.0, 388.2) 2. 3. 4. Make drawCenter) draw a red circle (width and height can be 20) at centerX, centerY. You will need to cast them into integers.Solution
Here is the code for you:
package part2;
 import java.awt.Color;
 public class Data {
 // static variables
 static int count = 0;
 static float centerX = 0;
 static float centerY = 0;
 // member variables
 int x;
 int y;
 // static functions
 public static void print() {
 System.out.println(\"There are \" + count + \" data points.\");
 System.out.println(\"Centered at (\" + centerX + \", \" + centerY + \")\");
 }
   
 public static void drawCenter() {
         EZCircle.addCircle(centerX, centerY, 20, 20, Color.RED, false);
 }
 // member functions
 public Data(int _x, int _y) {
 x = _x;
 y = -y;
 centerX = (count * centerX + x) / (count + 1);
 centerY = (count * centerY + y) / (count + 1);
 count++;
 }
   
 public void draw() {
         EZLine l;
         l = EZ.addLine(x, y, centerX, centerY, Color.BLACK);
 }
   
 }



