Question: PROBLEM SOLVING: (20 marks) Using modular programming approach, write a C++ program that able to calculate the effective resistance of n resistors connected in parallel.

 PROBLEM SOLVING: (20 marks) Using modular programming approach, write a C++

program that able to calculate the effective resistance of n resistors connected

in parallel. To ensure that the program able to perform the calculation,

the value entered by a user must be a correct value, which

mean the input value must not zero (O) and must a positive

value. Otherwise, the program displays a warning message and asks the user

PROBLEM SOLVING: (20 marks) Using modular programming approach, write a C++ program that able to calculate the effective resistance of n resistors connected in parallel. To ensure that the program able to perform the calculation, the value entered by a user must be a correct value, which mean the input value must not zero (O) and must a positive value. Otherwise, the program displays a warning message and asks the user to reenter resistor's value. The program is expected to produce the following output. Note: Arrays must be used to store all the data. How many resistors you have in the connection? 3 Enter value for resistor 1 in ohm: 4 Enter value for resistor 2 in ohm: -1 Resistor value must positive or not zero value. Reenter resistor 2 values: 0 Resistor value must positive or not zero value. Reenter resistor 2 values: 1 Enter value for resistor 3 in ohm: 5 The stored resistor values are as follows. 415 The effective resistance is 0.69 Press any key to continue... Figure 6.9: Expected output Provide the following Design the structure diagram and algorithm for the whole program 17 marks) 1. Write down your complete source code. Include documentation for the program at appropriate lines of code. (10 marks) Activatbeddindows Compile the program and enter random inputs. Number of outputs must be based on the options provided in the program Go to Settings to marryate APPENDIX //Code Example1.cpp //Program 6.1: Working with arrays * The main function calls a user-defined function named ceaspata without transfers anything The RRAICHU reads the input from the user up to 10 integer numbers. Then, it displays it in reverse order. #include #include >data; } //Display the input in reverse order cout =0; i--) [ cout using namespace std: void Dead back); //prototype for ceatabac function void ceva Secdek (char let[], int Jastaindex); //prototype for cexrasetustion int main) ( cea chart); //call ceadhhac function and transfer nothing cout >let[i //ifexit the loop if (let(41-'.') break; // the last index of array let bewIndex-ii =8; j--) cout #include using namespace std; const int NO_OF_ROWS - 2; const int NO_OF_COLS = 4: typedef float NewlypeINO_OF_ROWS] [NO_OF_COLS]; //declares a new data type // which is a 2 dimensional array of Floats Newlypeval; // defines va as a 2 dimensional array of dextype void getratat); //prototype of getrata void displayDataNewlype, array); //prototype of diarhayData, int maint) [ getratat); //call getrata, function and transfer nothing cout> vall.com.pas ][col.Posis } } displayDatalval); //call diarlas Data function and transfer array va } 17 diaplavata // // task: This function displays all entered inputs // // data in the array containing wat // data returned: none //*************************** ***** void displaybata (wtype array) Activate Go to Settin for (int row..res. 0; row.ros. #include >data; } //Display the input in reverse order cout =0; i--) [ cout using namespace std: void Dead back); //prototype for ceatabac function void ceva Secdek (char let[], int Jastaindex); //prototype for cexrasetustion int main) ( cea chart); //call ceadhhac function and transfer nothing cout >let[i //ifexit the loop if (let(41-'.') break; // the last index of array let bewIndex-ii =8; j--) cout #include using namespace std; const int NO_OF_ROWS - 2; const int NO_OF_COLS = 4: typedef float NewlypeINO_OF_ROWS] [NO_OF_COLS]; //declares a new data type // which is a 2 dimensional array of Floats Newlypeval; // defines va as a 2 dimensional array of dextype void getratat); //prototype of getrata void displayDataNewlype, array); //prototype of diarhayData, int maint) [ getratat); //call getrata, function and transfer nothing cout> vall.com.pas ][col.Posis } } displayDatalval); //call diarlas Data function and transfer array va } 17 diaplavata // // task: This function displays all entered inputs // // data in the array containing wat // data returned: none //*************************** ***** void displaybata (wtype array) Activate Go to Settin for (int row..res. 0; row.ros.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!