diff --git a/DeansBequest.iml b/DeansBequest.iml index 1efa802..011b29b 100644 --- a/DeansBequest.iml +++ b/DeansBequest.iml @@ -48,5 +48,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/voltag/volt.java b/src/voltag/volt.java new file mode 100644 index 0000000..7cb6fb5 --- /dev/null +++ b/src/voltag/volt.java @@ -0,0 +1,82 @@ +package voltag; + +import java.util.Arrays; + +public class volt +{ + double[] voltage = new double[72]; + double mean; + + public volt(){} + + public volt(double[] Voltage) + { + this.voltage=Voltage; + } + + public double calc_mean() + { + double avg=0; + for (int i=0;i bigger || voltage[i] < smaller ) + { + hours10[count] = voltage[i]; + count++; + } + + } + //from one to another by 15% + double[] hours15 = new double[72]; + int count2 = 0; + while(count2 < 71) + { + for(int j = 0; j < voltage.length; j++) + { + int limit = voltage.length - 2; + if(j <= limit) + { + double change = Math.abs(voltage[j] - voltage[j + 1]); + if(change > mean * 1.15) + { + hours15[j] = voltage[j]; + hours15[j+1] = voltage[j+1]; + + } + } + + } + count2++; + } + + return "The hours more than 10% of mean are: " + Arrays.toString(hours10) + "\nAdjacent hours of voltage difference more than 15% of mean are: " + Arrays.toString(hours15); + + + } +} diff --git a/src/voltag/voltTest.java b/src/voltag/voltTest.java new file mode 100644 index 0000000..ab24722 --- /dev/null +++ b/src/voltag/voltTest.java @@ -0,0 +1,40 @@ +package voltag; + +import java.util.Arrays; +import java.util.Random; + +import static org.junit.Assert.*; + +public class voltTest +{ + + @org.junit.Test + public void calc_mean() + { + Random r = new Random(); + double[] feb = new double[72]; + Arrays.fill(feb, 100); + volt v1 = new volt(feb); + v1.calc_mean(); + double mean = v1.getMean(); + + assertEquals(100,v1.getMean(),0); + } + + + + @org.junit.Test + public void report() + { + Random r = new Random(); + + double[] hours = new double[72]; + for(int i = 0; i < hours.length; i++) + hours[i] = r.nextInt(50,80); + + volt v1 = new volt(hours); + v1.setMean(10); + System.out.println(v1.report()); + + } +} \ No newline at end of file