Question

In: Computer Science

1. Coding Assignment the program will start the menu calling the method extractLargestAndSmallestYourName(), which is specified...

1. Coding Assignment

the program will start the menu calling the method extractLargestAndSmallestYourName(), which is specified as below.
 The method extractLargestAndSmallestYourName() will receive 2 array of integers as arguments, which are denoted as array number 1 and array number 2.
 The method will then search for the largest value and the smallest value. The search will also track from which array(s) these values can be found; and
 The information will be return an array, which has the two (2) groups of data as follows,
1) The first group involves the largest value and from which array(s) and has the following structure (see the sample output for details):
largestValue numberOfArrayWithLargestValue {listOfArray}
2) The second group involves the smallest value and from which array(s) and has the following structure (see the sample output for details):
smallestValue numberOfArrayWithSmallestValue {listOfArray}
 The method MUST NOT MODIFY the existing arrays given as arguments.
Note also that
 No global variables and data are allowed. All methods (as if you need them) must be written and no library/package methods are allowed.
 Only output streaming through System.out and Scanner(System.in) (with their supportive methods) are allowed to be used.

by using java programming

Solutions

Expert Solution

Code - Main.java


public class Main
{
//method to be called with 2 array as arguement and return the smallest
public static int [][] extractLargestAndSmallestYourName(int number1[], int number2[]){
//variable declare initialize max1 = first number of number1 array and same for max2
int max1=number1[0],max2=number2[0],min1=999999,min2=999999,i;
//first array extract the maximum and minimum
for(i=0;i<number1.length;i++){
if(max1<number1[i])
max1 = number1[i];
if(min1>number1[i])
min1 = number1[i];
}
//second array extract the maximum and minimum
for(i=0;i<number2.length;i++){
if(max2<number2[i])
max2 = number2[i];
if(min2>number2[i])
min2 = number2[i];
}
//initialize 2d array 2 store data for max and min and corresponding from which array
int a[][] = new int[2][2];
//if max1 is greater than max2 means max foound in array 1 is greater than max found in array 2
if(max1>max2){
//store the result in array
a[0][0] = max1;
a[0][1] = 1;
}
else{
a[0][0] = max2;
a[0][1] = 2;
}
//if min1 is greater than min2 means min foound in array 1 is greater than min found in array 2
if(min1>min2){
//store the result in array
a[1][0] = min2;
a[1][1] = 2;
}
else{
a[1][0] = min1;
a[1][1] = 1;
}
return a;
  
}
   public static void main(String[] args) {
   //array first with some random number
   int num1[] = {32, 54,23,65,34,76,34,12,43,545};
  
   //array second with some random number
   int num2[] = {53,65,34,12,15,56,97,56,76,87,2};
   //call the method extractLargestAndSmallestYourName and store value in 2 dimensional array b
   int b[][] = extractLargestAndSmallestYourName(num1,num2);
   //print the largest and smallest result
   System.out.println("Largest number found is "+b[0][0]+" from array "+b[0][1]);
   System.out.println("Smallest number found is "+b[1][0]+" from array "+b[1][1]);
   }
}

Screenshots -


Related Solutions

Write a program in C++ coding that utilizes a DO-WHILE loop to redisplay a menu to...
Write a program in C++ coding that utilizes a DO-WHILE loop to redisplay a menu to the user. Ask the user to input their favorite SuperHero and display a positive or funny comment about the chosen SuperHero. If RBG is chosen, display "You can't spell TRUTH without RUTH." Utilize a Do-While Loop to redisplay the menu to the user after item 1, 2 or 3 is executed. If item 4 is chosen, end the program. If the user chooses 4,...
PYTHON CODING Create a method for the Binary Search Tree (deleteNode) that deletes a specified node...
PYTHON CODING Create a method for the Binary Search Tree (deleteNode) that deletes a specified node identified by its value, and rearranges the descendants of the deleted node to ensure the resulting Tree meets the requirements of a Binary Search Tree. a) Discuss and justify your approach to address each possible case. b) Is the new tree (with the deleted node removed) unique? Discuss your answer. Discuss method's Big-O notation. Add proper and consistent documentation to identify code sections or...
PYTHON CODING Create a method for the Binary Search Tree (deleteNode) that deletes a specified node...
PYTHON CODING Create a method for the Binary Search Tree (deleteNode) that deletes a specified node identified by its value, and rearranges the descendants of the deleted node to ensure the resulting Tree meets the requirements of a Binary Search Tree. a) Discuss and justify your approach to address each possible case. b) Is the new tree (with the deleted node removed) unique? Discuss your answer. Discuss method's Big-O notation. Add proper and consistent documentation to identify code sections or...
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that...
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that meets the following requirements (NOTE: your program statements should follow the order of the requirements and each requirement should correspond to only one assembly instruction): Loads the hexadecimal equivalent of 23710 into register 13 using an immediate bitwise OR instruction Loads the hexadecimal equivalent of 183410 into register 17 using an immediate bitwise OR instruction Performs the bitwise AND operation on the operands stored...
In this assignment you are going to use the menu you created in Assignment 1 to...
In this assignment you are going to use the menu you created in Assignment 1 to test both your Double and Integer classes. You should add functionality to the menu to allow you test the add, sub, mul, div functions for instances of both classes You are going to have make a modification to your menu class. Currently it uses an array to hold a fixed amount of menu items. While this may be OK for most applications we want...
C++ Assignment 1) Write a C++ program specified below: a) Include a class called Movie. Include...
C++ Assignment 1) Write a C++ program specified below: a) Include a class called Movie. Include the following attributes with appropriate types: i. Title ii. Director iii. Release Year iv. Rating (“G”, “PG”, “PG-13”, etc) - Write code that instantiates a movie object using value semantics as text: - Write code that instantiates a movie object using reference semantics: - Write the print_movie method code: - Write Constructor code: - Write Entire Movie class declaration
BEFORE YOU START: Before working on this assignment you should have completed Assignment 1. PROGRAM STATEMENT...
BEFORE YOU START: Before working on this assignment you should have completed Assignment 1. PROGRAM STATEMENT AND REQUIREMENTS: You will implement in Java the WIFI troubleshooting program you created in Assignment 1 with the following additional conditions: At the end of the program, you will ask if the client wants to purchase a regular router for $50 or a super high-speed router for $200, adding the cost to the total amount the client needs to pay. Once your program calculates...
Write a C++ program that start the assignment by creating a file named pointerTasks.cpp with an...
Write a C++ program that start the assignment by creating a file named pointerTasks.cpp with an empty main function, then add statements in main() to accomplish each of the tasks listed below. Some of the tasks will only require a single C++ statement, others will require more than one. For each step, include a comment in your program indicating which step you are completing in the following statement(s). The easiest way to do this is copy and paste the below...
Write a C++ program that start the assignment by creating a file named pointerTasks.cpp with an...
Write a C++ program that start the assignment by creating a file named pointerTasks.cpp with an empty main function, then add statements in main() to accomplish each of the tasks listed below. Some of the tasks will only require a single C++ statement, others will require more than one. For each step, include a comment in your program indicating which step you are completing in the following statement(s). The easiest way to do this is copy and paste the below...
1) Using the FASB coding system as a guide, which depreciation method would you recommend for...
1) Using the FASB coding system as a guide, which depreciation method would you recommend for a business within the computer manufacturing industry? a * Do you consider that management should be able to determine both the number of years of useful life and the salvage value of fixed assets? b * Should it be part of the responsibilities of the accountant to define the standard that should be applied to all assets? 2) taking into account GAAP and the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT