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
MAVERICK [17]
3 years ago
10

Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMile

s. Sample output for the given program:Min miles: -10Max miles: 40#include using namespace std;int main( ) { const int NUM_ROWS = 2; const int NUM_COLS = 2; int milesTracker[NUM_ROWS][NUM_COLS]; int i = 0; int j = 0; int maxMiles = -99; // Assign with first element in milesTracker before loop int minMiles = -99; // Assign with first element in milesTracker before loop milesTracker[0][0] = -10; milesTracker[0][1] = 20; milesTracker[1][0] = 30; milesTracker[1][1] = 40; /* Your solution goes here */ cout << "Min miles: " << minMiles << endl; cout << "Max miles: " << maxMiles << endl;}
Computers and Technology
1 answer:
ryzh [129]3 years ago
6 0

Answer:

Following are th program in the C++ Programming Language.

#include <iostream>//set Header files

using namespace std;//set namespace

//define main function

int main()

{

//set integer constants variable

const int NUM_ROWS = 2;

//set integer constants variable

const int NUM_COLS = 2;

//set integer type array

int milesTracker[NUM_ROWS][NUM_COLS];

//set integer type variable and initialize to 0

int i = 0;

//set integer type variable and initialize to 0

int j = 0;

//set integer type variable and initialize to -99

int maxMiles = -99;

//set integer type variable and initialize to -99

int minMiles = -99;

//initialize the value in the two dimensional array

milesTracker[0][0] = -10;

milesTracker[0][1] = 20;

milesTracker[1][0] = 30;

milesTracker[1][1] = 40;

//here is the solution  

maxMiles = milesTracker[0][0];

minMiles = milesTracker[0][0];

/*set for loop to find the minimum miles and maximum miles*/

for (i = 0; i < NUM_ROWS; i++)

{

 for (j = 0; j < NUM_COLS; j++)

 {

 //set if condition for maxMiles is the bigger than

   if (milesTracker[i][j] > maxMiles)

   //initialize milesTracker[i][j] to maxMiles

     maxMiles = milesTracker[i][j];

   //set if condition for minMiles is the smaller than

   if (milesTracker[i][j] < minMiles)

   //initialize milesTracker[i][j] to maxMiles

     minMiles = milesTracker[i][j];

 }

}

//print output

cout << "Min miles: " << minMiles << endl;

//print output

cout << "Max miles: " << maxMiles << endl;

return 0;

}

<u>Output:</u>

Min miles: -10

Max miles: 40

Explanation:

Here, we define the main method and inside it:

  • set two constant integer type variable and initialize to 2
  • set integer type two-dimensional array and pass constant variables in it.
  • Set two integer type variable and initialize to 0 then, again set two integer type variable and initialize to -99.
  • Initialize the values in the two-dimensional array.
  • Set two for loop for the two-dimensional array to find the minimum and maximum miles.
  • Set two if condition to find bigger or smaller miles.

Finally, print the maximum and the minimum miles then, return 0.

You might be interested in
Which of the following statements is/are correct? a. At the network layer, entitlement can map identity and/or attributes to fun
AlekseyPX

Answer:

Option D

Explanation:

An Entitlement is an option to utilize, get to or devour an application or asset, commonly for a charge. For instance, a client may buy an Entitlement to utilize an application in ceaselessness (a "unending" permit), or they may buy a period restricted option to utilize an application, (for example, a one-year membership permit).

7 0
2 years ago
Return the "centered" average of an array of ints, which we'll say is the mean average of the values, except ignoring the larges
denpristay [2]

Answer:

The code to this question can be defined as follows:

public double centeredAverage(ArrayList<Integer> nums) //defining a method centeredAverage that accepts an array nums

{

   if ((nums == null) || (nums.size() < 3))//define if block for check simple case value

   {

       return 0.0;//return float value

   }

   double sum = 0; //defining a double variable sum

   int smallest = nums.get(0);//defining integer variable and assign value

   int largest = nums.get(0);//defining integer variable and assign value

   for (int i = 0; i < nums.size(); i++) //defining for loop for stor ith value

   {

       int value = nums.get(i);//defining integer value variable to hold nums value

       sum = sum + value;//use sum variable for add value

       if (value < smallest)//defining if block to check value less then smallest

           smallest = value;//hold value in smallest variable  

       else if (value > largest)//defining else if block that checks value greater them largest value

           largest = value; //hold value in largest variable

   }

   sum = sum - largest - smallest;  // use sum to decrease the sum largest & smallest value

   return (sum / (nums.size() - 2)); //use return keyword for return average value

}

Explanation:

In the question, data is missing, that's why the full question is defined in the attached file please find it.

In the given code a method "centeredAverage" is used that accepts an array in its parameter and inside the method, if block is used that checks the cash value if it is true, it will return a float value.

In the next step, two integers and one double variable is defined, that use the conditional statement for check hold value in its variable and at the last use return keyword for return average value.

3 0
3 years ago
What is the duty of business to contribute to the well-being of society
NikAS [45]

Answer:

To be able to explain what’s wrong and what needs to be done

Explanation:

So if your looking at a worksheet and the costumer needs help they are gonna ask you about it so your gonna need to be able to explain what’s going on and what needs to be/get done

5 0
3 years ago
Referat noaptea la școala cu sfârșit de groază​
solniwko [45]

Te ajut eu daca vrei tu la refera

7 0
2 years ago
Communication is used to satisfy instrumental goals, which means ________ .
Ann [662]
Communication comes in lots of types, therefore, it also has lots of goals and purposes. One of the purpose of communication is to satisfy instrument goals. Instrument goals here refers to the goal that focuses on convincing others to act in an appropriate way. This is most applicable in situations when someone had to deal with others. 
3 0
3 years ago
Read 2 more answers
Other questions:
  • What is the function of series-parallel circuit
    9·1 answer
  • With a _____ network connection, the computers and other devices on the network are physically connected via cabling to the netw
    13·1 answer
  • #include &lt;iostream&gt;
    9·1 answer
  • If K is a foreign key in relation R1, then
    10·1 answer
  • Technology has proliferated in Kenya and Somaliland, with text messages used to replace cash, creating mobile money use that, on
    11·1 answer
  • CMS is a content management system that collects, organization, publishes, and manages creative content. Right...?
    9·1 answer
  • I CANT DO SKIN MODS ON BRAWLHALLA RIGHT!!!! IM SO MADDDDDDDDDDD
    11·1 answer
  • What are the advantages of saving files in a cloud? <br>Please help!! ​
    11·2 answers
  • Barbara, an employee, has properly connected her personal wireless router to a network jack inside her office. The router is una
    7·1 answer
  • 7 TH GRADE QUESTION...PLS HELP
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!