Hi for this question I will offer 3000 pts and if your code compiles and I under
ID: 3535444 • Letter: H
Question
Hi for this question I will offer 3000 pts and if your code compiles and I understand you code I will repost the question for another 3000 pts so 6000 pts total.
This project requires that I read the data from the .txt file, store it in an array and calculate the average of the data and frequency distributions of the data in increment of 10, from 81-90,91-100 etc. I need some help with calculating the frequency of the array read from a data.txt file. My code compiles and prints out the data from the .txt file and contains all the class structures I need it to complete this assignment.Â
1. I am not sure how to create an object of class Frequency in the driver.
2. I am having trouble with the calculated monthly average (MnthlyAvg).
3. I am having trouble with the frequency calculations in (class frequency extends Calculations).Â
I will not rate any bad answers and i will repost this question for another 3000pts for the person who can help me solve this problem.
the notepad file data.txt contains:
123 134 122 128 116 96 83 144 143 156 128 138 121 129 117 96 87 148 149 151 129 138 127 126 115 94 83 142
below is my code.
===========
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.*;
import java.io.*;
public class YetAnotherTest{
public static void main(String[] args) throws IOException{Â Â
FileReader file = new FileReader("data.txt");
double[] integers = new double [28];
int i=0;Â Â
try {
Scanner read = new Scanner(file);
while(read.hasNext()){
integers[i] = read.nextDouble();
i++;
}
read.close();
}
catch(Exception e){
e.printStackTrace();
}
System.out.println("info from data.txt: "+Arrays.toString(integers)+" ");
for(int j=0;j<integers.length;j++){
System.out.println("Day no. "+(j+1)+" Millions of Gallons: "+integers[j]);
}
}
public static abstract class Average{
private double [] integers;
private double MnthlyAvg;
private double sum;
DecimalFormat fmt = new DecimalFormat("0.####");
public Average(double [] INTvalues, double MOavg){
double [] integer=INTvalues;
MnthlyAvg=MOavg;
System.out.println(MnthlyAvg);
}
public double getMonthlyAverage(double []w,double MA,double SUM){
w=integers;
double sum=SUM=0;
double MnthlyAvg=MA=0;
for(int i=0;i<integers.length;i++)
sum+=integers[i];
MnthlyAvg+=((double)sum /(double) integers.length);
System.out.println(MnthlyAvg);
return MnthlyAvg;
}
public String toString(){
String str = new String("This Months Average: "+/*getMnthlyAvg()+*/" Million gallons per day.");
return str;
}
public abstract String getMnthly_Report();
}///endAverage
public static class Frequency extends Average{
private double[] variables;///not sure what or where to place variables in this class
public Frequency(double [] INTvalues, double MOavg){
super(INTvalues,MOavg);
}
public String getMnthly_Report(){
return "************************************************************* ***************Â "
+"Monthly Service Report. ******************* "+"************************************************************* "+ super.toString()+" ************************************************************* "+"Frequency distrubution for this month:"+" Between 81-90: "/*this frequwncy+*/
+" Between 91-100: "/*+this freqency*/
+" Between 101-110: "/*+this frequency*/
+" Between 111-120: "/*+this frequency*/
+" Between 121-130: "/*+this frequency*/
+" Between 131-140: "/*+this frequency*/
+" Between 141-150: "/*+this frequency*/
+" Between 151-160: "/*+this frequency*/
+" ********** End of Monthly Service Report. ***************** ************************************************************* ";
}
}//ends Frequency extends Average
}//ends YetAnotherTest
Explanation / Answer
//found it
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.