(The Location class) Design a class named Location for locating a maximal value and its location in a two-dimensional array. The class contains public data fields row, column, and maxValue that store the maximal value and its indices in a two-dimensional array with row and column as int types and maxValue as a double type.
Write the following method that returns the location of the largest element in a two-dimensional array:
public static Location locatelargest(double[] [] a)
The return value is an instance of Location. Write a test
Trending nowThis is a popular solution!
Chapter 9 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Problem Solving with C++ (10th Edition)
Digital Fundamentals (11th Edition)
Programming in C
Starting Out with C++ from Control Structures to Objects (9th Edition)
Java How To Program (Early Objects)
- use javascriptarrow_forwardRewrite the client program to use the Baby class that you have done using ArrayList. You should also have the following function in this new client program: a) Enter details for each baby (name and age) and thus populate the Baby ArrayList b) Calculate and display the average age of all babies in the ArrayList c) Ask the user to enter the name of a baby, and then remove it from the ArrayList d) Allow the user to add new baby information in the ArrayList e) Output the details of each baby from the ArrayList (name and age) Compare this client program using the ArrayList with the client program you have done using array, comment on the differences between the two. Modify your client program in the last question, by adding a sort function such that when that option is selected, it sorts the ArrayList using the baby names in alphabetical order and output the details in the sorted ArrayList to a CSV (sortedbabylist.csv) file. public class Baby { private String name; private int age;…arrow_forwardAttach code and screenshotarrow_forward
- Question 2: (TicTacToe Class) Create a class TicTacToe that will enable you to write a complete program to play the game of tic-tac-toe. The class contains as private data a 3-by-3 two-dimensional array of integers. The constructor should initialize the empty board to all zeros. Allow two human players. Wherever the first player moves, place a 1 in the specified square. Place a 2 wherever the second player moves. Each move must be to an empty square. After each move, determine whether the game has been won or is a draw. If you feel ambitious, modify your program so that the computer makes the moves for one of the players. Also, allow the player to specify whether he or she wants to go first or second.arrow_forwardSultan Qaboos University Department of Computer Science COMP2202: Fundamentals of Object Oriented Programming Assignment # 2 (Due 5 November 2022 @23:59) The purpose of this assignment is to practice with java classes and objects, and arrays. Create a NetBeans/IntelliJ project named HW2_YourId to develop a java program as explained below. Important: Apply good programming practices: 1- Provide comments in your code. 2- Provide a program design 3- Use meaningful variables and constant names. 4- Include your name, university id and section number as a comment at the beginning of your code. 5- Submit to Moodle the compressed file of your entire project (HW1_YourId). 1. Introduction: In crowded cities, it's very crucial to provide enough parking spaces for vehicles. These are usually multistory buildings where each floor is divided into rows and columns. Drivers can park their cars in exchange for some fees. A single floor can be modeled as a two-dimensional array of rows and columns. A…arrow_forwardObjective: Design a program that uses two-dimensional arrays, classes and objects Assignment: Write a program that plays a tic-tac-toe game with the user. Define a class TicTacToe with the necessary data and functions to play the game. Use a 2-D char array with three rows and three columns as the game board. The class should also have the following functions: A constructor to initialize the board. I suggest either asterisk ('*') or characters '1' through '9'. A function to play the user's turn, fill in the board with either an 'X' or 'O' given row and column number (1-3) A function to play the computer's turn. This function will determine the row and column number to be filled in. You can use a simple algorithm such as look for the first space available, or random number generation. Complex AI algorithms will only be accepted with an explanation of its behavior via a zoom meeting. A function to verify if there is a win. This can be broken down by calling 3 separate private…arrow_forward
- Alert dont submit AI generated answer.arrow_forward1.) How to outpit an element of an array? 2.) How to put element to an array? 3.) How to use array with a looping structur?arrow_forwardTask 3: Arrays (Java) Al Zila Hospital takes readings of blood sugar level for its inpatients every day. Write a Java application to create a class with attributes patient name, patient_ID, age, readings of blood sugar test stored in an array. Define methods to get the patient details, print their details and calculate highest, lowest and average blood sugar levels based on the readings recorded. Sample Test case: Enter Patient details: Name: Salim, ID: P2218, Age: 53, No of readings: 5 Enter the readings in mg/dL: 160 140 120 140 150 Highest blood sugar level: 160, Lowest blood sugar level: 120, Average blood sugar level: 142 Do you want to Continue for other patient Y/N?arrow_forward
- Question 17 (23 points) Write a method that takes an array of type double and returns a boolean value. The method returns true if the sum of the even-indexed elements of the parameter array is larger than the sum of the odd-indexed elements, otherwise the method returns false. The method's header is public static boolean compare(double[] in) Sample run double[] in = {}: boolean out = compare(in); System.out.println(“Result: "+ out); double[] in = {-5, -3.1, 2.5, 5.1, 7.1, 3.7, -5}; boolean out = compare(in); System.out.println(“Result: " + out); Output Result: false Result: falsearrow_forwardDon't use vector array .using c++ languagearrow_forwardRotate Right k cells (use python) Consider an array named source. Write a method/function named rotateRight( source, k) that rotates all the elements of the source array to the right by 'k' positions. You must execute the method by passing an array and number of cells to be shifted. After calling the method, print the array to show whether the elements have been shifted properly. Example: source=[10,20,30,40,50,60] rotateRight(source,3) After calling rotateRight(source,3), printing the array should give the output as: [ 40, 50, 60, 10, 20, 30]arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education