Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chapter 7 Programming Challenge 1 7 Starting Out With Java Tony Gladdis 4 th Edition - Must follow Templates and added specifications ADDED SPECIFICATIONS: Must

Chapter 7 Programming Challenge 17 Starting Out With Java Tony Gladdis 4th Edition - Must follow Templates and added specifications ADDED SPECIFICATIONS: Must create a class Array2D for the methods defined in the textbook.
Must add additional getAllRowTotals() method to Array2D which returns an array of answers, e.g., the 0 index of the returned array is the total for row 0 of the array passed to it.
Must add additional getAllColTotals() method to Array2D which returns an array of answers, e.g., the 0 index of the returned array is the total for col 0 of the array passed to it.
Must create a class Array2DTest to exercise methods defined in Array2D. Array2D must be usable without instances.
Array2D methods shall assume that the arrays are of ints.
Must not have the same conceptual task coded in more than one place.
Array2DTest has getInput() method that defines the 2D arrays values and passes that array back to main() via a return statement.
Input is hard-coded with the values, i.e., declare & define a 3-row, 4-col 2D array with values. I will then paste in my own set of values for testing. So code robustly, i.e., do NOT code assuming that the 2D array is 3x4.
Array2DTest has output() method that receives the 2D array of initial values and displays a report of the lowest, highest, total, count, and average for each array separately and displays the cumulative totals for each row and column. The data for this output will be obtained by output() by directly calling the appropriate Array2D class methods.
Have Array2D make use of the method(s) of the previous assignment. TEMPLATES HERE: ARRAY DATA TEMPLATE: public class Ch07Pc11_ArrayDataTEMPLATE
{
public double getTotal(double[] nums)
{
double total = nums[0];
for (int i=1; i < nums.length; i++)
{
total += nums[i];
}
return total;
}
public double getAverage (double[] nums)
{
double total = nums[0];
for (int i=1; i < nums.length; i++)
{
total += nums[i];
}
return total / nums.length;
}
public double getHighest(double[] nums)
{
double maxNum = nums[0];
for (int i=1; i < nums.length; i++)
{
if (maxNum < nums[i])
{
maxNum = nums[i];
}
}
return maxNum;
}
public double getLowest(double[] nums)
{
double minNum = nums[0];
for (int i=1; i < nums.length; i++)
{
if (minNum > nums[i])
{
minNum = nums[i];
}
} return minNum;
}
}
ARRAY TEST TEMPLATE : import java.io.*;
public class Ch07Pc11_ArrayTestTEMPLATE
{
public static void main(String[] args)
{
Ch07Pc11_ArrayDataTEMPLATE arrFunc = new
Ch07Pc11_ArrayDataTEMPLATE();
double[] vals ={5,18,6,2,0,8,0,-6,3};
System.out.printf( "Total: %f
"
+" Ave: %f
"
+" Max: %f
"
+" Min: %f
",
arrFunc.getTotal( vals ),
arrFunc.getAverage( vals ),
arrFunc.getHighest( vals ),
arrFunc.getLowest( vals ));
}
}

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

More Books

Students also viewed these Databases questions

Question

6. Conclude with the same strength as in the introduction

Answered: 1 week ago

Question

7. Prepare an effective outline

Answered: 1 week ago