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

You need to use the node structure provided below struct node { string name; dou

ID: 3721959 • Letter: Y

Question

You need to use the node structure provided below

struct node {

   string name;

   double resistance;

   double voltage_across;

   double power_across;

};

Implement a series network that has “unlimited” number of resistors stored in a C++ “vector”. In general, to solve this problem you will do the following:

-Prompt for the input voltage

-Group input resistor values and store them in a vector.

-Solve for series current

-Calculate total circuit power

-Calculate the voltage “drop” across each resistor

-Calculate the power dissipated by each resistor.

-Display Network

You need to create at least five functions

Some/most of the above “bullet” points could/should become individual functions to solve this problem.

Please test your functions with a variety of inputs in main().

To determine the series current you will first need to add up all the series resistors (Rtotal). Once you have Rtotal the current simply becomes:

Series Current = Voltage Source / Rtotal

You can use this Current to determine the power dissipation and voltage drops across the individual resistors.

Can modify code below or start from scratch using C++

Explanation / Answer

#include <iostream>

#include <string>

#include <vector>

using namespace std;

vector<double> r,va,pa; // intialising vector resistance, voltage across, power across of type double

vector<string> nam; // intialising vector resistance of type string

// You must use this structure

struct node {

string name;

double resistance;

double voltage_across;

double power_across;

}N1; // declaring N1

// An Example of the type of function you may want to create

void nodeName() {

cout << "Enter Node Name: ";

cin >> N1.name;

nam.push_back(N1.name);

}

void resistanceStore(){

cout << "Resistor Value: ";

cin >> N1.resistance;

r.push_back(N1.resistance);

}

double total_res(){

double tot_res=0;

for(int i=0;i<r.size();i++){

tot_res+=r[i];

}

return tot_res;

}

double ser_current(double sv,double tot_res){

double s_c;

s_c = sv/tot_res;

return s_c;

}

void volt_across(double s_c){

for(int i=0;i<r.size();i++){

N1.voltage_across = s_c * r[i];

va.push_back(N1.voltage_across);

}

}

void pow_across(double s_c){

for(int i=0;i<r.size();i++){

N1.power_across = va[i] * s_c;

pa.push_back(N1.power_across);

}

}

void displayInfo(){

for(int i=0;i<r.size();i++){

cout <<endl<<"Node Name: "<< nam[i] << endl;

cout << "Node Voltage: " << va[i] << "-Volts" << endl;

cout << "Node Resistance: " << r[i] << "-Ohms" << endl;

cout << "Node Power: " << pa[i] << "-Watts" << endl<<endl;

}

}

//

// The comments indicate good places to covvert code to short functions

//

int main() {

int nodes;

cout<<"Enter number of nodes you want : ";

cin>>nodes;

// Enter source voltage

double source_voltage;

cout << "Enter Source Voltage: ";

cin >> source_voltage;

  

// Enter basic Node Information

// N1.name = nodeName();

//cout << "Resistor Value: ";

//cin >> N1.resistance;

for(int i=0;i<nodes;i++){

cout<<"Enter node name and resistance of that node : "<<endl;

nodeName();

resistanceStore();

}

// Calculate series current for the one-node network

double total_resistance = total_res();

double series_current = ser_current(source_voltage, total_resistance);

// Calculate voltage across the restistor

//N1.voltage_across = series_current * N1.resistance;

volt_across(series_current);

// Calculate the power across the resistor

//N1.power_across = N1.voltage_across * series_current;

pow_across(series_current);

// Display Network Information

cout << "Series Network: " << endl;

cout << "Source Voltage: " << source_voltage << "-Volts" << endl;

cout << "Total Resistance: " << total_resistance << "-Ohms" << endl;

cout << "Series Current: " << series_current << "-Amperes" << endl;

  

  

displayInfo();

// Display Node information

/*cout << "Node Name: " << N1.name << endl;

cout << "Node Voltage: " << N1.voltage_across << "-Volts" << endl;

cout << "Node Resistance: " << N1.resistance << "-Ohms" << endl;

cout << "Node Power: " << N1.power_across << "-Watts" << endl;*/

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