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

C++ programing, please don\'t handwrite out code Imagine a thin metal plate surr

ID: 3841914 • Letter: C

Question

C++ programing, please don't handwrite out code

Imagine a thin metal plate surrounded by neat sources along each edge, with the edges head at different temperatures. After a short time, the temperature at each location on the plate will settle into a steady state This can be modeled by dividing the plate into a discrete grid of cells and simulating the change in temperature of each cell overtime: At each time step, the temperate in each interior cell will be the average of four of its surrounding neighbors: T(ij) = |T(i-lj) + T(i-lj| - T(ij-1) - T(i, j+1)/4 Develop a C++program to determine the steady state temperature distribution the plate by representing the plate as a two-dimensional array with NROWS rows and NCOLS columns. NROWS and NCOLS should be declared as global constants. Declare 2 separate two-dimensional arrays named temp and old. Array old will be used to maintain current values of the grid temperature and array temp will be used to compute the new values obtained at each successive time step using the equation above. Prompt the user and enter temperatures values for the top, bottom. left, right sides. Also prompt and enter an initial temperature T(i, j) for the interior cells. For this lab, you may initialize all the interior cells to a single, user-input temperature)

Explanation / Answer

#INCLUDE <<IOSTREAM.H>
#DEFINE NROWS 20
#DEFINE NCOLS 20
VOID(DISPLAY(DOUBLE TEMP[NCOLS][NROWS]))
{
   INT X,Y;

   COUT<< "The current temperature values for the cells are"

   FOR (X = 0; X < NROWS; X++)
   {
       FOR (Y=0; Y < NCOLS; Y++)
       {
           COUT << "CELL (" << X << ")(" << Y << ") EQUALS" << TEMP[X][Y] ;
       }
   }
}

INT MAIN ()

   {
       DOUBLE TEMP[NCOLS][NROWS], OLD[NROWS][NCOLS],I=0,J=0,L=0;M=0,CONV;
       BOOL STEADY[NROWS][NCOLS];
       INT TOP, BOTTOM, LEFT, RIGHT,INNER;
      
       COUT << "ENTER THE INITIAL TEMPERATURE OF TOP CELLS";
       CIN >> TOP;
       COUT << "ENTER THE INITIAL TEMPERATURE OF BOTTOM CELLS";
       CIN >> BOTTOM;
       COUT << "ENTER THE INITIAL TEMPERATURE OF LEFT CELLS";
       CIN >> LEFT;
       COUT << "ENTER THE INITIAL TEMPERATURE OF RIGHT CELLS";
       CIN >> RIGHT;
              
       FOR (I=0;I<NROWS;I++)
       {
           OLD [0][I] = TOP;
           OLD [I][0] = LEFT;
           OLD [NROW-1][I] = BOTTOM;
           OLD [I][NROW-1] = RIGHT;
       }

       COUT << "ENTER THE INITIAL VALUE OF INNER CELLS";
       CIN >> INNER;
      
       FOR (I=1;I<NROWS;I++)
       {
           FOR (J=1;I<COLS;J++)
           {
               OLD[I][J] = INNER;
           }
       }

       FOR (L=0;I<NROWS;L++)
       {
           FOR (M=0;I<COLS;M++)
           {
               DO
               {
                   FOR (I=0;I<NROWS;I++)
                   {
                       FOR (J=0;I<COLS;J++)
                       {
                           TEMP[I][J] = 0.25 * OLD[I-1][J]+TEMP[I+1][J]+TEMP[I][J-1]+TEMP[I][J+])
                           IF (TEMP[I][J]-OLD[I][J]) > CONV
                           {STEADY[I][J] = FALSE}
                           ELSE
                           {STEADY[I][J] = TRUE}                  
                       }
                   }

                          
               }WHILE (STEADY[L][M]=FALSE);
              
           }
       }

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