Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with code and Ive attached the skelton for MultiStatsArrays and GUI. import java.awt.*; import java.util.Random; //for our random number generator public class

I need help with code and Ive attached the skelton for MultiStatsArrays and GUI.

image text in transcribed

image text in transcribed

import java.awt.*; import java.util.Random; //for our random number generator public class MultiStatsArray { private int rowSize; /umber of rows private int columnSize; /umber of columns private int[][]stats; // an array of integers //default constructor //by default the array has 10 rows and 5 columns MultiStatsArray() { rowSize = 10; columnSize = 5; stats = new int[rowSize][columnSize]; } public void display(Graphics g) { int x = 50; int y = 40; //displaying the array for(int i = 0; i = lowRange and  

//////////////////////////// GUI ///////////////////////////////////

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MultiStatsArrayGUI extends JFrame implements ActionListener { //set up buttons to control the MultiArray private JButton maxButton; private JButton minButton; private JButton sumButton; private JButton avgButton; private JButton aButton; private JButton numberButton; private JButton startOverButton; private JButton specificColButton; private JButton specificRowButton; private JButton sortButton; private JPanel panel; /*instantiate your MultiArray object called grades creates array of size 10 rows and 5 columns */ private MultiStatsArray grades = new MultiStatsArray( ); public static void main(String[] args) { MultiStatsArrayGUI demo = new MultiStatsArrayGUI(); demo.setSize(400,400); demo.createGUI(); demo.setVisible(true); } private void createGUI() { setDefaultCloseOperation(EXIT_ON_CLOSE); Container window = getContentPane(); window.setLayout(new FlowLayout()); panel = new JPanel(); panel.setPreferredSize(new Dimension(300, 200)); panel.setBackground(Color.white); window.add(panel); //buttons startOverButton = new JButton("New Array"); window.add(startOverButton); startOverButton.addActionListener(this); maxButton = new JButton("Maximum"); window.add(maxButton); maxButton.addActionListener(this); minButton = new JButton("Minimum"); window.add(minButton); minButton.addActionListener(this); sumButton = new JButton("Sum"); window.add(sumButton); sumButton.addActionListener(this); avgButton = new JButton("Average"); window.add(avgButton); avgButton.addActionListener(this); aButton = new JButton("Number of A's"); window.add(aButton); aButton.addActionListener(this); numberButton = new JButton("Lucky 7?"); window.add(numberButton); numberButton.addActionListener(this); specificColButton = new JButton("2nd column"); window.add(specificColButton); specificColButton.addActionListener(this); specificRowButton = new JButton("3rd row"); window.add(specificRowButton); specificRowButton.addActionListener(this); sortButton = new JButton("Sort"); window.add(sortButton); sortButton.addActionListener(this); /* invokes method to fill array with random numbers between 1 and 100 */ grades.fillArray(); } //Button and TextField event handler public void actionPerformed(ActionEvent event) { Graphics g = panel.getGraphics(); Object source = event.getSource(); /*cover up old display before drawing the new values. Then set the color back to black */ g.setColor(Color.white); g.fillRect(0, 0, 300, 200); g.setColor(Color.black); if (source == minButton) g.drawString("Minimum is: " + grades.getMin(), 50, 20); else if (source == maxButton) g.drawString("Maximum is: " + grades.getMax(), 50, 20); else if (source == sumButton) g.drawString("Sum is: " + grades.getSum(), 50, 20); else if (source == avgButton) g.drawString("Average is: " + grades.getAverage(), 50, 20); else if (source == aButton) g.drawString("Number of A's = " + grades.countValues(90, 100), 50, 20); else if (source == numberButton) g.drawString("Lucky 7 Y or N: " + ( ( grades.isValueFound( 7 ) )? 'Y' : 'N' ), 50, 20); else if (source == specificColButton){ g.drawString("The total of the 2nd column is: " + grades.getColumnSum(1), 50, 20);} else if (source == specificRowButton){ g.drawString("The total of the 3rd row is: " + grades.getRowSum(2), 50, 20);} else if (source == startOverButton){ grades.fillArray(); g.drawString("New Values" , 50, 20);} else if (source == sortButton) { grades.sortArray(); g.drawString("Sorted! ", 50, 20); } g.setColor(Color.black); grades.display(g); //lets see the array of random numbers! } } 
CSC110AA and CIS163AA Ch 7 Program 2 - MultiStatsArray (15 pts) Submit the following List of source code with comments to document Screen shot of your program GUI. To get a screen shot of your program GUI Click on your GUI output to select it. Press calt buttons to get a copy. (this may vary slightly depending on your computer) Or Use the Snipping Tool. Save thei 1. Implement the MultiStatsArray class based on the UML below. Download the MultiStatsArray.java skeleton class and use as a starting point. This skeleton class has empty methods (stubs) for you to finish. Download and test with MultiStatsArrayGUI.java. Do not make any changes to MultiStatsArrayGUl.java. As you complete each method in MultiStats Array, compile your class and check by running MultiStatsArrayGUI Part of this assignment is for you to analyze the actionPerformed method in MultiStatsArrayGUI.java. Pay close attention to how the MultiStatsArray object grades invokes methods defined in the MultiStatsArray class. MultiStatsArray //the number of rows in the array rowSize : int -columnSize: int//the number of columns in the array stats: int] //a 2 dimensional int array named stats +MultiStatsArray() //constructor Set rowSize to 10, columnSize to 5. Creates array stats. Code is givern +display(Graphics g): void //display the contents of the array. Code is given. +fillArray(): void +getMax(): int +getMin): int +getSum): int +getAverage(): double find and return the average of all values in the array +countValues(int lowRange, int highRange): int /fill the int array stats with random data in the range 0- 100 //find and return largest value - max /Ifind and return smallest value - min find and return sum of all values in the array //count and return the number of values in the array that are-lowRange and buttons to get a copy. (this may vary slightly depending on your computer) Or Use the Snipping Tool. Save thei 1. Implement the MultiStatsArray class based on the UML below. Download the MultiStatsArray.java skeleton class and use as a starting point. This skeleton class has empty methods (stubs) for you to finish. Download and test with MultiStatsArrayGUI.java. Do not make any changes to MultiStatsArrayGUl.java. As you complete each method in MultiStats Array, compile your class and check by running MultiStatsArrayGUI Part of this assignment is for you to analyze the actionPerformed method in MultiStatsArrayGUI.java. Pay close attention to how the MultiStatsArray object grades invokes methods defined in the MultiStatsArray class. MultiStatsArray //the number of rows in the array rowSize : int -columnSize: int//the number of columns in the array stats: int] //a 2 dimensional int array named stats +MultiStatsArray() //constructor Set rowSize to 10, columnSize to 5. Creates array stats. Code is givern +display(Graphics g): void //display the contents of the array. Code is given. +fillArray(): void +getMax(): int +getMin): int +getSum): int +getAverage(): double find and return the average of all values in the array +countValues(int lowRange, int highRange): int /fill the int array stats with random data in the range 0- 100 //find and return largest value - max /Ifind and return smallest value - min find and return sum of all values in the array //count and return the number of values in the array that are-lowRange and

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

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

=+ For what reasons can and do unions go on strike?

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago