Homework 3 10-01-09

Homework 3 10-01-09 - "Enter value of voltage...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Alex Fidalgo 10/01/09 Intro to Programming E-115- C, E-115-LK I pledge my honor that I have abided by the Stevens Honor System.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is when the program built successfully. This is when the program ran successfully.
Background image of page 2
This is trial one of the program
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is trial two of the program
Background image of page 4
This is the graph of trial one speeds This is the graph of trial two speeds
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
#include <iostream> #include <cmath> #include <string> using namespace std; int main () { double dspeed, accuracy, pspeed, incvoltage, pvoltage, cspeed, cvoltage, d, nexvoltage, nexspeed, Error; char done( 'n' ); // this is used to terminate loop. char dummy; // See whether you understnad why I use this below cout << "Enter desired motor speed between 1.5 and 8.5: " ; cin >> dspeed; cout << endl << "Enter accuracy of motor speed desired (in %): " ; cin >> accuracy; cout << endl << "Enter starting value for voltage: " ; cin >> pvoltage; cout << endl <<
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: &quot;Enter value of voltage increment for start: &quot; ; cin &gt;&gt; incvoltage; // voltage incriment pspeed = 3.0 + (2.1 * pow(pvoltage,2))/1.3 + (0.3 * (pow(pvoltage,2))); cvoltage = pvoltage + incvoltage; cspeed = 3.0 + (2.1 * pow(cvoltage,2))/1.3 + (0.3 * pow(cvoltage,2)); do { d = ((cvoltage - pvoltage) / (cspeed - pspeed)); nexvoltage = cvoltage + 0.1 * (d * (dspeed-cspeed)); nexspeed = 3.0 + (2.1 * pow(nexvoltage,2)) / 1.3 + (0.3 * pow(nexvoltage,2)); cout &lt;&lt; endl &lt;&lt; &quot;Next Voltage: &quot; &lt;&lt; nexvoltage &lt;&lt; endl &lt;&lt; &quot;Desired Speed: &quot; &lt;&lt; dspeed &lt;&lt; endl &lt;&lt; &quot;Next Speed: &quot; &lt;&lt; nexspeed; cin &gt;&gt; dummy; /* V1 = V2; T2 = T3; V2 = V3; T2 = T3; */ pvoltage = cvoltage; pspeed = cspeed; cvoltage = nexvoltage; cspeed = nexspeed; Error = ((abs(cspeed - dspeed) / dspeed)) * 100; } while (Error&gt;=accuracy); cout &lt;&lt; endl &lt;&lt; &quot;Congrats &quot; ; return 0; }...
View Full Document

Page1 / 6

Homework 3 10-01-09 - &amp;amp;quot;Enter value of voltage...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online