Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help completing this assignement: I have included what i already have at the bottom. Classes Utility class - TwoDimRaggedArrayUtility The class TwoDimRaggedArrayUtility will

I need help completing this assignement: I have included what i already have at the bottom.

Classes Utility class - TwoDimRaggedArrayUtility

The class TwoDimRaggedArrayUtility will follow the provided Javadoc and will contain the following methods: Method readFile pass in a file and return a two-dimensional ragged array of doubles Method writeToFile pass in a two-dimensional ragged array of doubles and a file, and writes the ragged array into the file. Each row is on a separate line and each double is separated by a space. Method getTotal pass in a two-dimensional ragged array of doubles and returns the total of the elements in the array. Method getAverage pass in a two-dimensional ragged array of doubles and returns the average of the elements in the array (total/num of elements). Method getRowTotal pass in a two-dimensional ragged array of doubles and a row index and returns the total of that row. Row index 0 is the first row in the array. Method getColumnTotal - pass in a two-dimensional ragged array of doubles and a column index and returns the total of that column. Column index 0 is the first column in the array. If a row doesnt contain that column, it is not an error, that row will not participate in this method. Method getHighestInRow - pass in a two-dimensional ragged array of doubles and a row index and returns the largest element in that row. Row index 0 is the first row in the array. Method getHighestInRowIndex - pass in a two-dimensional ragged array of doubles and a row index and returns the index of the largest element in that row. Row index 0 is the first row in the array. Method getLowestInRow - a two-dimensional ragged array of doubles and a row index and returns the smallest element in that row. Row index 0 is the first row in the array. Method getLowestInRowIndex - a two-dimensional ragged array of doubles and a row index and returns the index of the smallest element in that row. Row index 0 is the first row in the array. Method getHighestInColumn - pass in a two-dimensional ragged array of doubles and a column index and returns the largest element in that column. Column index 0 is the first column in the array. If a row doesnt contain that column, it is not an error, that row will not participate in this method. Method getHighestInColumnIndex - pass in a two-dimensional ragged array of doubles and a column index and returns the index of the largest element in that column. Column index 0 is the first column in the array. If a row doesnt contain that column, it is not an error, that row will not participate in this method. Method getLowestInColumn - pass in a two-dimensional ragged array of doubles and a column index and returns the smallest element in that column. Column index 0 is the first column in the array. If a row doesnt contain that column, it is not an error, that row will not participate in this method. Method getLowestInColumnIndex - pass in a two-dimensional ragged array of doubles and a column index and returns the index of the smallest element in that column. Column index 0 is the first column in the array. If a row doesnt contain that column, it is not an error, that row will not participate in this method. Method getHighestInArray - pass in a two-dimensional ragged array of doubles and returns the largest element in the array. Method getLowestInArray - pass in a two-dimensional ragged array of doubles and returns the smallest element in the array. Utility class HolidayBonus

The class HolidayBonus will follow the provided Javadoc and will contain the following methods: Method calculateHolidayBonus pass in a two-dimensional ragged array of doubles, and the bonus amount for the store with the highest sales in a category, the bonus amount for the store with the lowest sales in a category and bonus amount for all other stores. It will return an array of doubles which represents the holiday bonuses for each of the stores in the district. The first entry in the returned array [0] will represent the holiday bonus for the store at [0] in the two-dimensional ragged array of doubles. You will be using methods from the TwoDimRaggedArrayUtility when needed. Method calculateTotalHolidayBonus pass in a two-dimensional ragged array of doubles, and the bonus amount for the store with the highest sales in a category, the bonus amount for the store with the lowest sales in a category and bonus amount for all other stores. It will return a double which represents the total of all Holiday Bonuses for the District. You will be using methods from the TwoDimRaggedArrayUtility when needed. GUI Application provided for you Uses methods of TwoDimRaggedArrayUtility and HolidayBonus When the Load Sales Data button is selected the sales data is read from a file and displayed on the screen with the sales data as well as the totals for each store and the totals for each category. The largest sales for each category is highlighted in green. The smallest sales for each category is highlighted in red. The holiday bonus for each store is displayed as well as the total of holiday bonuses. The file contains a row for each store and each double in the row is separated by a space Student must provide two additional input files and a screenshot of the results of each. Each file will have at least 4 rows and up to 6 numbers on each row. They must represent ragged arrays. JUnit Test Student will implement TwoDimRaggesArrayUtilityTestSTUDENT Student will implement HolidayBonusTestSTUDENT

package Package;

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.*;

import java.util.*;

import java.lang.*;

public class TwoDimRaggedArrayUtility {

//Read file

public double [][] readFile(File f)

{

double [][] newAry=new double [6][];

try

{

BufferedReader bb=new BufferedReader (new FileReader(f));

String line;

int kk=0;

while ( (line=bb.readLine()) != null)

{

String[] tt=line.split("");

int nlen=tt.length;

newAry[kk]=new double [nlen];

for (int aa=0; aa

{

newAry[kk][aa]=

Double.parseDouble(tt[aa]);

}

kk++;

}

bb.close();

}

catch (Exception ep)

{

ep.printStackTrace();

}

return newAry;

}

}

//Write to file

public void writeToFile (double[][] ragAry, File f)

{

try

{

BufferedWriter bb=new BufferedWriter (new FileWriter(f));

for (int kk=0; kk

{

for (int aa=0; aa

{

bb.write(ragAry[kk][aa]+ "");

}

bb.newLine();

}

bb.close();

}

catch(Exception ep)

{

ep.printStackTrace();

}

}

//get total of 2nd ragged array

public double getTotal(double [][] ragAry)

{

double douSum=0;

for (int kk=0; kk

{

for (int aa=0;aa

{

douSum += ragAry[kk][aa];

}

}

return douSum;

}

//Get average

public double getAverage(double[][]ragAry)

{

double douSum=0;

int nCnt=0;

for (int kk=0;kk

{

for (int aa=0; aa

{

douSum+= ragAry[kk][aa];

nCnt +=1;

}

}

return new Double(douSum/nCnt);

}

//Get total

public double getRowTotal (double[][] ragAry, int idd)

{

double douSum=0;

for (int aa=0;aa

{

douSum += ragAry[idd][aa];

}

return douSum;

}

//Get Column total

public double getColumnTotal (double[][] ragAry, int idd)

{

double douSum=0;

for (int kk=0;kk

{

if(idd<=ragAry[kk].length-1)

douSum +=ragAry[kk][idd];

}

return douSum;

}

//Get highest in the row

public double getHighestRow (double[][] ragAry, int idd)

{

double highElem=ragAry[idd][0];

for (int aa=0;aa

{

if (ragAry[idd][aa]>highElem)

highElem=ragAry[idd][aa];

}

return highElem;

}

//Get lowest in the row

public double getLowestInRow (double[][] ragAry, int idd)

{

double lwElem=ragAry[idd][0];

for (int aa=0;aa

{

if (ragAry[idd][aa]

lwElem=ragAry[idd][aa];

}

return lwElem;

}

//Get Highest in column

public double getHighestInColumn (double[][] ragAry, int idd)

{

double highElem=ragAry[0][idd];

for (int kk=0;kk

{

if(idd<=ragAry[kk].length-1)

{

if (ragAry[kk][idd]>highElem)

highElem=ragAry[kk][idd];

}

}

return highElem;

}

//Get Lowest in column

public double getLowestInColumn (double[][] ragAry, int idd)

{

double lwElem=ragAry[0][idd];

for (int kk=0;kk

{

if (idd<=ragAry[kk].length-1)

if (ragAry[kk][idd]

lwElem=ragAry[kk][idd];

}

return lwElem;

}

//Get highest element

public double getHighestInArray (double [][] ragAry)

{

double highElem=ragAry[0][0];

for (int kk=0;kk

{

for (int aa=0;aa

{

if (ragAry[kk][aa]>highElem)

highElem= ragAry[kk][aa];

}

}

return highElem;

}

//Get lowest elemenet

public double getLowestInArray (double [][] ragAry)

{

double lwElem=ragAry[0][0];

for (int kk=0; kk< ragAry.length;kk++)

{

for (int aa=0;aa

{

if (ragAry[kk][aa]

lwElem = ragAry [kk][aa];

} } return lwElem; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions