Menu

[Solved]Java Programming Please Help Create Method Bonuses Calculated Based Much Retail Store Sold Q37134593

JAVA PROGRAMMING Please help me create this method

The bonuses are calculated based on how much each retail storesold in each category. The retail store with the highest amountsold in a category will receive $5,000. The retail store with thelowest amount sold in a category will receive $1,000. All otherretail stores in district #5 will receive $2,000. If a retail storedidn’t sale anything in a category, or they have a negative salesamount, they are not eligible for a bonus in that category. If onlyone retail store sold items in a category, they are eligible toreceive only the bonus of $5000 for that category.

  1. Method calculateHolidayBonus – pass in atwo-dimensional ragged array of doubles, and the bonus amount forthe store with the highest sales in a category, the bonus amountfor the store with the lowest sales in a category and bonus amountfor all other stores. It will return an array of doubles whichrepresents the holiday bonuses for each of the stores in thedistrict. The first entry in the returned array [0] will representthe holiday bonus for the store at [0] in the two-dimensionalragged array of doubles. You will be using methods from theTwoDimRaggedArrayUtility when needed.

TwoDimRaggedArrayUtility:::

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class TwoDimRaggedArrayUtility {

   public static double getAverage(double[][] data){
       int count = 0;
       double average = 0;
       for (double[] arr : data) {
           for (double ar1: arr) {
              if (ar1 == 0) continue;//comment this if youwant 0’s to be counted in number of elements count
              ++count;
              average += ar1;
           }
       }
       return average / count;
   }

   public static double getColumnTotal(double[][]data, int col) {
       double columtotal =0;  
       int row = 0;
       while( row < data.length )
       {
           if( col <data[row].length )
           { columtotal +=data[row][col]; }
           ++row; }

       returncolumtotal;  
   }public static double getHighestInArray(double[][]data) {
       double highest = 0; for (double[]d1 : data)
       { for (double d2 : d1)
           {if (d2 >highest)
              {highest = d2;
              }
           }
       }
       return highest;

   }   public static doublegetHighestInColumn(double[][] data, int col) {double longestRow =0;
       for (int row = 0; row <data.length; row++)
       {
           if(data[row].length > longestRow) longestRow =data[row].length;
       }
       double highest =Double.MIN_VALUE;

       for ( int row = 0; row <data.length; row++)

           if( col <data[row].length && data[row][col] > highest)

              highest = data[row][col];  

       return highest;
   }

   public static double getHighestInRow(double[][]data, int row) {

       int col;  
       double rowHighest = data[row][0];

       for (col =0;col<data[row].length;col++ )
       {
           if (data [row][col] > rowHighest)
           {
              rowHighest= data[row] [col];
           }

       }   returnrowHighest;
   }
   public static int getHighestInColumnIndex(doubledata[][], int col_index){

       int highest_ind = 0;

       for(int i=0; i<data.length;i++){

          if(data[i].length>col_index){

             if(data[i][col_index]>data[highest_ind][col_index])

                  highest_ind = i; }
       }return highest_ind;

   }

   public static int getHighestInRowIndex(double[][]data, int row) {
       int index = 0;
       for (int i = 0; i <data[row].length; ++i) {
           if (data[row][i]> data[row][index]) {
              index = i;
           }
       }
       return index;

   }
   public static double getLowestInArray(double[][]data)
   {
       double lowest = data[0][0];
       for (double[] d : data)
       {
           for (double dd :d)
           {
              if (dd < lowest)
              {
                  lowest = dd;
              }
           }
       }
       return lowest;
   }

   public static double getLowestInColumn(double[][]dataSet, int col) {

       double longestRow = 0;
       for (int row = 0; row <dataSet.length; row++)
       {
           if(dataSet[row].length > longestRow)
              longestRow = dataSet[row].length;

       }
       double lowest =Double.MAX_VALUE;

       for ( int row = 0; row <dataSet.length; row++)

           if ( col <dataSet[row].length && dataSet[row][col] < lowest)
              lowest = dataSet[row][col];

       return lowest;

   }
   public static int getLowestInColumnIndex(doubledata[][], int col_index){

       int highest_ind = 0;

       for(int i=0; i<data.length;i++){

          if(data[i].length>col_index){

             if(data[i][col_index]<data[highest_ind][col_index])

                  highest_ind = i;

           }
       }

       return highest_ind;

   }

   public static double getLowestInRow(double[][]data, int row)
   {
       double lowestRow =data[row][0];

       for (int j = 0; j <data[row].length; j++)
       {
           if (lowestRow> data[row][j])
           {
              lowestRow = data[row][j];

           }
       }
       return lowestRow;
   }

   public static int getLowestInRowIndex(double[][] data,int row)
   {
       int index = 0;
       for (int i = 0; i <data[row].length; ++i) {
           if (data[row][i]< data[row][index]) {
              index = i;
           }
       }
       return index;

   }
   public static double getRowTotal(double[][] data, introw)
   {
       double totalRow = 0;
       for (int j = 0; j <data[row].length; j++)
       {
           totalRow +=data[row][j];
       }
       return totalRow;
   }
   public static double getTotal(double[][] data)
   {
       double total = 0;
       for (double[] d : data)
       {
           for (double dd :d)
           {
              total += dd;
           }
       }
       return total;
   }

Expert Answer


Answer to JAVA PROGRAMMING Please help me create this method The bonuses are calculated based on how much each retail store sold i… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *