Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
bartleby
Concept explainers
Question
thumb_up100%
JAVA PROGRAM
Chapter 7. PC #16. 2D Array Operations
Write a program that creates a two-dimensional array initialized with test data. Use any primitive data type that you wish. The program should have the following methods:
• getTotal. This method should accept a two-dimensional array as its argument and return the total of all the values in the array.
• getAverage. This method should accept a two-dimensional array as its argument and return the average of all the values in the array.
• getRowTotal. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The method should return the total of the values in the specified row.
• getColumnTotal. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a column in the array. The method should return the total of the values in the specified column.
• getHighestInRow. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the
subscript of a row in the array. The method should return the highest value in the specified row of the array.
• getLowestInRow. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The method should return the lowest value in the specified row of the array.
Demonstrate each of the methods in this program. The name of the file is read from command-line arguments: args[0]
Inpu11.txt
1 2 3
4 5 6
7 8 9
4 5 6
7 8 9
Input2.txt
555.66 333.44 123.45
778.88 900.00 123.12
234.23 567.98 12.12
778.88 900.00 123.12
234.23 567.98 12.12
Input3.txt
555.66 333.44 123.45 555.66 333.44 123.45
778.88 900.00 123.12 778.88 900.00 123.12
234.23 567.98 12.12 234.23 567.98 12.12
778.88 900.00 123.12 778.88 900.00 123.12
234.23 567.98 12.12 234.23 567.98 12.12
Input4.txt
555.66 333.44 123.45
778.88 900.00 123.12
234.23 567.98 12.12
555.66 333.44 123.45
778.88 900.00 123.12
234.23 567.98 12.12
555.66 333.44 123.45
778.88 900.00 123.12
234.23 567.98 12.12
778.88 900.00 123.12
234.23 567.98 12.12
555.66 333.44 123.45
778.88 900.00 123.12
234.23 567.98 12.12
555.66 333.44 123.45
778.88 900.00 123.12
234.23 567.98 12.12
Test Case 1
Command Line arguments:
input1.txt
Row 0 Subtotal: 6.000\n
Row 1 Subtotal: 15.000\n
Row 2 Subtotal: 24.000\n
Column 0 Subtotal: 12.000\n
Column 1 Subtotal: 15.000\n
Column 2 Subtotal: 18.000\n
Array Total: 45.000\n
Row 1 Subtotal: 15.000\n
Row 2 Subtotal: 24.000\n
Column 0 Subtotal: 12.000\n
Column 1 Subtotal: 15.000\n
Column 2 Subtotal: 18.000\n
Array Total: 45.000\n
Test Case 2
Command Line arguments:
input2.txt
Row 0 Subtotal: 1012.550\n
Row 1 Subtotal: 1802.000\n
Row 2 Subtotal: 814.330\n
Column 0 Subtotal: 1568.770\n
Column 1 Subtotal: 1801.420\n
Column 2 Subtotal: 258.690\n
Array Total: 3628.880\n
Row 1 Subtotal: 1802.000\n
Row 2 Subtotal: 814.330\n
Column 0 Subtotal: 1568.770\n
Column 1 Subtotal: 1801.420\n
Column 2 Subtotal: 258.690\n
Array Total: 3628.880\n
Test Case 3
Command Line arguments:
input3.txt
Row 0 Subtotal: 2025.100\n
Row 1 Subtotal: 3604.000\n
Row 2 Subtotal: 1628.660\n
Column 0 Subtotal: 1568.770\n
Column 1 Subtotal: 1801.420\n
Column 2 Subtotal: 258.690\n
Column 3 Subtotal: 1568.770\n
Column 4 Subtotal: 1801.420\n
Column 5 Subtotal: 258.690\n
Array Total: 7257.760\n
Row 1 Subtotal: 3604.000\n
Row 2 Subtotal: 1628.660\n
Column 0 Subtotal: 1568.770\n
Column 1 Subtotal: 1801.420\n
Column 2 Subtotal: 258.690\n
Column 3 Subtotal: 1568.770\n
Column 4 Subtotal: 1801.420\n
Column 5 Subtotal: 258.690\n
Array Total: 7257.760\n
Test Case 4
Command Line arguments:
input4.txt
Row 0 Subtotal: 1012.550\n
Row 1 Subtotal: 1802.000\n
Row 2 Subtotal: 814.330\n
Row 3 Subtotal: 1012.550\n
Row 4 Subtotal: 1802.000\n
Row 5 Subtotal: 814.330\n
Row 6 Subtotal: 1012.550\n
Row 7 Subtotal: 1802.000\n
Row 8 Subtotal: 814.330\n
Column 0 Subtotal: 4706.310\n
Column 1 Subtotal: 5404.260\n
Column 2 Subtotal: 776.070\n
Array Total: 10886.640\n
Row 1 Subtotal: 1802.000\n
Row 2 Subtotal: 814.330\n
Row 3 Subtotal: 1012.550\n
Row 4 Subtotal: 1802.000\n
Row 5 Subtotal: 814.330\n
Row 6 Subtotal: 1012.550\n
Row 7 Subtotal: 1802.000\n
Row 8 Subtotal: 814.330\n
Column 0 Subtotal: 4706.310\n
Column 1 Subtotal: 5404.260\n
Column 2 Subtotal: 776.070\n
Array Total: 10886.640\n
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
This is a popular solution
bartleby
Trending nowThis is a popular solution!
bartleby
Step by stepSolved in 3 steps with 4 images
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- In visual basic Print out the last value in a single-dimensional array.arrow_forwardWhen an array is passed as a parameter to a method, modifying the elements of the array from inside the function will result in a change to those array elements as seen after the method call is complete. O True O Falsearrow_forwardFYI: Please write the code in Pseudocode (no programming language please) 1. Write pseudocode to load a single array with data. Then search that array for a match. Here are the specifics. You do NOT have to write the entire program. Load the array with data from a file named customerNumbers Ask the user to enter their customer number Search the array for the customer number If you find a match output FOUND If there is no match output NOT FOUNDarrow_forward
- Programming language: Processing from Java Question attached as photo Topic: Use of Patial- Full Arraysarrow_forward10. Lottery Application Write a Lottery class that simulates a lottery. The class should have an array of five integers named lotteryNumbers. The constructor should use the Random class (from the Java API) to generate a random number in the range of 0 through 9 for each element in the array. The class should also have a method that accepts an array of five integers that represent a per- son's lottery picks. The method is to compare the corresponding elements in the two arrays and return the number of digits that match. For example, the following shows the lotteryNumbers array and the user's array with sample numbers stored in each. There are two matching digits (elements 2 and 4). lotteryNumbers array: User's array: 7 4 4 2 1 3 7 3 In addition, the class should have a method that returns a copy of the lotteryNumbers array. Demonstrate the class in a program that asks the user to enter five numbers. The program should display the number of digits that match the randomly generated...arrow_forwardProblem Description - JAVA PROGRAMMING Use a Two-dimensional (3x3) array to solve the following problem: Write an application that inputs nine numbers, each of which is between 1 and 10, inclusive. Display the array after the user inputs each value. Rotate/flip the array by changing places. Make the rows columns and vice versa. You have to move the elements to their new locations. Remember to validate the input and display an error message if the user inputs invalid data. Documentation and the screenshot(s) of the results. Example: 1 2 3 4 5 6 7 8 9 the result will be : 1 4 7 2 5 8 3 6 9arrow_forward
- Java Programarrow_forwardJAVA PROGRAM: Monkey Business A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 ×ばつ 5 array, where each row represents a different monkey and each column represents a different day of the week. The program should first have the user input the data for each monkey, or use constant values rather than asking user for input. Then it should create a report that includes the following information: Display 3X5 array first. Average amount of food eaten per day by the whole family of The least amount of food eaten during the week by any one The greatest amount of food eaten during the week by any one Input Validation: Do not accept negative numbers for pounds of food eaten.arrow_forwardLab Activity for the students: Exercise 5: Write a program that asks the user to input 8 numbers and save them in a 2D array with 4 rows and 2 columns. The program finds the sum of all elements and prints the array in reverse order. (1 Mark ) Example : If the inputs are 12, 7, 23, 86, 40, 64, 97, 55. Then, the program will print: 55 97 64 40 86 23 7 12 Sum = 384arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education