Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this question, you will use a 2-dimensional array of floating point values to

ID: 3645901 • Letter: I

Question

In this question, you will use a 2-dimensional array of floating point values to store 3 sensor readings for 2 locations. Write a program that asks the user for the 3 sensor readings for each location, storing them in the readings[] array, and then prints the sensor readings for each location and the average value for each location.

float readings[2,3];
Example:
Enter the sensor reading for location 0, reading 0: 1.25
Enter the sensor reading for location 0, reading 1: 1.50
Enter the sensor reading for location 0, reading 2: 1.00
Enter the sensor reading for location 1, reading 0: 2.00
Enter the sensor reading for location 1, reading 1: 2.25
Enter the sensor reading for location 1, reading 2: 1.75
The sensor readings for location 0 are:
1.25, 1.50, 1.00
The average of the readings at location 0 is: 1.25

The sensor readings for location 1 are:
2.00, 2.25, 1.75
The average of the readings at location 0 is: 2.00

Note: It is possible to do this question without arrays, but if you do not use arrays in the way we descirbed above, you will get no credit for this question!

I dont even know how to design the program to prompt the user to enter values for the array . Please help!

Explanation / Answer

please rate - thanks

#include <iostream>
#include <iomanip>
using namespace std;
int main( )
{int i,j;
float readings[2][3],sum;
for(i=0;i<2;i++)
    for(j=0;j<3;j++)
          { cout<<"Enter the sensor reading for location "<<i<<", reading "<<j<<": ";
          cin>>readings[i][j];
          }
for(i=0;i<2;i++)
   {sum=0;
    cout<<"The sensor readings for location "<<i<<" are: ";
    for(j=0;j<2;j++)
        {cout<<readings[i][j]<<", ";
        sum+=readings[i][j];
        }
    cout<<readings[i][j]<<endl;
    sum+=readings[i][j];
    cout<<"The average of the readings at location "<<i<<" is: "
         <<setprecision(2)<<fixed<<sum/3.<<endl<<endl;
}
system("pause");
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote