Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fix the code so it does the following Herre is example of the outputs The code may look long but its a easier fix suppose

Fix the code so it does the following
Herre is example of the outputs
The code may look long but its a easier fix suppose to my teacher
Be sure to look closely at the example
Cuircuit parmeter is different then the nodes the nodes are the individual calculations
Sample 1:
Enter Voltage: 100
Enter Resistance (0 to exit): 100
Enter Resistance (0 to exit): 0
Circuit Parameters:
Total Resistance: 100 ohms
Input Voltage: 100 volts
Series Current: 1 Amp
Total Power: 100 Watts
Node 0 Parameters:
Resistance: 100 ohms
Voltage: 100 volts
Power: 100 Watts
Sample 2:
Enter Voltage: 100
Enter Resistance (0 to exit): 50
Enter Resistance (0 to exit): 50
Enter Resistance (0 to exit): 0
Circuit Parameters:
Total Resistance: 100 ohms
Input Voltage: 100 volts
Series Current: 1 Amp
Total Power: 100 Watts
Node 0 Parameters:
Resistance: 50 ohms
Voltage: 50 volts
Power: 50 Watts
Node 1 Parameters:
Resistance: 50 ohms
Voltage: 50 volts
Power: 50 Watts
Then formar it so that it does the following
o start part B, please copy the source file from part A to a new project.
Convert part B to a class if it is not already and add a menu to your creation from part B. The menu should contain at least the following options:
Add a single resistor
Change Input voltage
Delete resistor
Edit resistor value
Group add a series of resistors. Gave the user the ability to add more than resistor at a time.
Display network
Quit program
The menu should be the part of your class. Each item in the menu will probably end up being a method in your class. A do-while loop and switch/case statement is probably best way to implement a menu.
#include
#include
#include
using namespace std;
//class circuit:
//public
// have it so resistance.at()
//V = I * R
//I is current
// might nd up needing the -> this ,statment
// needs some fine tuning
// calculate power, Power (W) = (Voltage (V)) * (Current (I))
// make class so
double Power(double current ,double voltage){
//turn power into vector while resistance !=0;
double power =0;
power=(current*voltage);
return power;
}
// calculate current , I = P / V
double Current(double resistance,double voltage){
//make current into vector
double current =0;
current=(voltage/resistance);
return current;
}
// displays current parameter outputs
double outputs(double resistance ,double voltage,double current , double power,double j ){
//have for loop that outputs power and restiance until their length
//cout<<"Node "<
// if statment is a test
if(j==0){
cout<<"circuit parameter: "<
cout<<"resistance: "<
cout<<"voltage: "<
cout<<"current: "<
cout<<"power: "<
cout<
}
// below is test
if(j>=1){
cout<<"Node "<
cout<<"resistance: "<
cout<<"voltage: "<
cout<<"power: "<
cout<
}
}
int main()
{
double voltage=0;
double resistance =0;
//double current=0;
//double power =0;
double count=0;
vector current;
vector power;
vector R;
double i=0;
cout<<"enter voltage: " ;
cin>>voltage;
do{ // part b code
cout<<"enter resistance (0 to exit) : ";
cin>>resistance;
cout<
R.push_back(resistance);
count++;
//cout<<"inside vector"<
current.push_back(Current(resistance,voltage));
power.push_back(Power(current.at(i),voltage));
// cout<<"current="<
//cout<<"power="<
//=Current(resistance,voltage);
//power=Power(current,voltage);
//if below is a test
i++;
}while(resistance!=0);
//does this while resistance does not equal 0
//current=Current(resistance,voltage);
//power=Power(current,voltage);
for(int j=0;j
outputs(R.at(j),voltage,current.at(j),power.at(j),j);
}
if(R.at(0)==0){
outputs(R.at(0),voltage,current.at(0),power.at(0),0);
}
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

3. How would you address the problems that make up the situation?

Answered: 1 week ago

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago