Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using visual studio and the program code below, modify the program code so the out put will display a graph line using the information given

Using visual studio and the program code below, modify the program code so the out put will display a graph line using the information given to you below:

When the switch shown in Figure 7.14 is closed at time t = 0, the voltage, V, across the capacitor, C, is given by this formula:

V = E(1 - e-t/RC)

E is the voltage of the battery.

R is the resistance in the circuit.

C is the value of the capacitance.

e is Euler's number (2.71828 . . .).

t is the time in seconds

image text in transcribed

Assuming E = 50, R = 4000, and C = 0.005, modify Program 7.13 to plot the voltage across the capacitor from t = 0 to t = 60 in increments of 2 seconds.

Program7.13

#include

#include

using namespace std;

int main()

{

const int MAXPOINTS = 100;

int i, npts, nval[MAXPOINTS];

double x, fval, ymin, ymax, width, sval[MAXPOINTS];

char label[] = " y axis";

char axis[] = "+---------------------------------------------------->";

char line[] = "| ";

ymax = 1.0e-5;

ymin = 1.0e5;

width = 53;

// load the data to be plotted and find the max and min values

i = 1;

for(x = -5.0; x

{

sval[i] = pow(x,3.0);

if (sval[i] > ymax) ymax = sval[i];

if (sval[i]

i++;

if (i >= MAXPOINTS) break; // don't exceed the maximum points

}

npts = i - 1;

// scale all the y values

for (i=1; i

{

fval = (sval[i] - ymin)/(ymax - ymin) * (width - 1) + 1;

nval[i] = fval + 0.5; // convert to an integer value

}

// produce the plot

cout

cout

cout

cout

for (i = 1; i

{

line[(nval[i] + 2)] = '*'; // set character to an asterisk

cout

line[(nval[i] + 2)] = ' '; // reset character to a blank

}

return 0;

}

Switch E Figure 7.14 a simple RC circuit

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_2

Step: 3

blur-text-image_3

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

What is the meaning of the term competitive intelligence ?

Answered: 1 week ago