1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
AnnZ [28]
3 years ago
11

Find the maximum value and minimum value in below mention code. Assign the maximum value to maxMiles, and the minimum value to m

inMiles. Sample output for the given program:
Min miles: -10
Max miles: 40
Here's what I have so far:

import java.util.Scanner;

public class ArraysKeyValue {
public static void main (String [] args) {
final int NUM_ROWS = 2;
final int NUM_COLS = 2;
int [][] milesTracker = new int[NUM_ROWS][NUM_COLS];
int i = 0;
int j = 0;
int maxMiles = 0; // Assign with first element in milesTracker before loop
int minMiles = 0; // Assign with first element in milesTracker before loop

milesTracker[0][0] = -10;
milesTracker[0][1] = 20;
milesTracker[1][0] = 30;
milesTracker[1][1] = 40;

//edit from here

for(i = 0; i < NUM_ROWS; ++i){
for(j = 0; j < NUM_COLS; ++j){
if(milesTracker[i][j] > maxMiles){
maxMiles = milesTracker[i][j];
}
}
}
for(i = 0; i < NUM_ROWS; ++i){
for(j = 0; j < NUM_COLS; ++j){
if(milesTracker[i][j] < minMiles){
minMiles = milesTracker[i][j];
}
}
}

//edit to here


System.out.println("Min miles: " + minMiles);
System.out.println("Max miles: " + maxMiles);
}
Computers and Technology
1 answer:
Kobotan [32]3 years ago
3 0

Answer:

Code works perfectly

Explanation:

There is nothing wrong with your program as it runs perfectly and displays the expected results.

You may need to compile with another compiler if you're not getting the required results.

I've added the source code as an attachment (unedited)

Download java
You might be interested in
2. Feet to Inches One foot equals 12 inches. Design a function named feetToInches that accepts a number of feet as an argument,
MariettaO [177]

Answer:

See the below the answer written in Matlab

Explanation:

function inches=feetToInches(feet)

prompt='enter the value of feet in digits';

feet=input(prompt)% ask for the value in feet that needs to be converted to inches

inches =feet*12; % converts feet to inches

x=['the value in inches is:  ',num2str(inches)];

disp(x) %display the result of the convertion

end

8 0
3 years ago
Which one of the following is the correct code snippet for calculating the largest value in an integer array list aList?
vodka [1.7K]

Answer:

Option a.  int max = aList.get(0); for (int count = 1; count < aList.size(); count++) { if (aList.get(count) > max) { max = aList.get(count); } }

is the correct code snippet.

Explanation:

Following is given the explanation for the code snippet to find largest value in an integer array list aList.

  1. From the array list aList, very first element having index 0 will be stored in the variable max (having data type int).
  2. By using for starting from count =1 to count = size of array (aList), we will compare each element of the array with first element of the array.
  3. If any of the checked element get greater from the first element, it gets replaced in the variable max and the count is increased by 1 so that the next element may be checked.
  4. When the loop will end, the variable max will have the greatest value from the array aList.

i hope it will help you!

7 0
3 years ago
Read 2 more answers
At the beginning of a project, what should be the focus?
podryga [215]
The answer is A I think
7 0
3 years ago
Expliquer les règles à respecter quand on fait une recherche sur internet.
Illusion [34]

Answer:

Explanation:

Step one

We must analyze all the possibilities like tools, search engines, and what kind of information we need.

Step two

We must administrate keywords, we can make a keywords research or hire a SEO expert.

Step three

We must study the first search and do notes about it, and get the first data.

Step forth

We can start with the entire research on the internet, we must visit several sites and levels surfing.

8 0
3 years ago
The field of informatics helps bring the right information to healthcare teams and patients at the right time which may improve
zalisa [80]

Answer:

True

Explanation:

The word informatics is derived from the French word Informatique and it describes the science of using  information & communication technology (ICT),  to communicate, for the management of knowledge, prevention of errors and supporting of decision making. The application of effective informatics to health care delivery will definately lead to better results.

6 0
3 years ago
Other questions:
  • After doing the route tracing to a particular IP addresses, paste the path of IP addresses that were taken from your IP address
    13·1 answer
  • When using a template to compose a memorandum which key on the keyboard moves the cursor to the next field
    15·1 answer
  • What kind of voltage do solar cells generate? Solar cells produce ______ voltage which is not usable by most household appliance
    15·1 answer
  • The counter in a for or while loop can have an explicit increment: for i=m:k:n. This advances the counter i by increment k each
    15·1 answer
  • Video Fundamentals
    6·1 answer
  • An online service allows users to integrate their phonebook with their social media profiles and stores it on the cloud. The pho
    12·1 answer
  • Help easy 50 points!!!!<br> How do i make someone be the brianliest? No crown thing is appering!!!!
    10·2 answers
  • 1. Who was able to complete the puzzle the fastest in Trial 1?
    15·1 answer
  • When an EC2 instance is being modified to have more RAM, is this considered Scaling Up or Scaling Out?
    5·1 answer
  • What do hard disk drive use to store data
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!