Modify the program by removing the inner loop. To do this, make sure there should be three input voltages for each piece of equipment. Code: using System; class Program { static void Main() { // Input the voltage data double [,] mat = {{1081,223.7,222.5,223.0}, {2061,220.2,227.0,225.1}, {2405,221.7,224.9,226.0}, {3368,222.9,223.8,226.7}}; int i,j; // Compute the Average of voltage of each equipment and all voltages double total = 0.0; for(i=0;i<4;i++) { double sum = 0.0; for(j=1;j<4;j++) { sum = sum + mat[i,j]; } total = total + sum; Console.WriteLine("Average voltage of equipment number : "+mat[i,0]+" = "+(sum/3)); } Console.Write("Average of all voltages = "+(total/12)); } }
Modify the
Code:
using System;
class Program
{
static void Main()
{
// Input the voltage data
double [,] mat = {{1081,223.7,222.5,223.0},
{2061,220.2,227.0,225.1},
{2405,221.7,224.9,226.0},
{3368,222.9,223.8,226.7}};
int i,j;
// Compute the Average of voltage of each equipment and all voltages
double total = 0.0;
for(i=0;i<4;i++)
{
double sum = 0.0;
for(j=1;j<4;j++)
{
sum = sum + mat[i,j];
}
total = total + sum;
Console.WriteLine("Average voltage of equipment number : "+mat[i,0]+" = "+(sum/3));
}
Console.Write("Average of all voltages = "+(total/12));
}
}
Step by step
Solved in 3 steps with 1 images