Homework 3 10-01-09

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

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

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.

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

View Full Document
This is when the program built successfully. This is when the program ran successfully.
This is trial one of the program

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

View Full Document
This is trial two of the program
This is the graph of trial one speeds This is the graph of trial two speeds

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

View Full Document
#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 <<
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: "Enter value of voltage increment for start: " ; cin >> 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 << endl << "Next Voltage: " << nexvoltage << endl << "Desired Speed: " << dspeed << endl << "Next Speed: " << nexspeed; cin >> 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>=accuracy); cout << endl << "Congrats " ; return 0; }...
View Full Document

{[ snackBarMessage ]}

Page1 / 6

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

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

View Full Document
Ask a homework question - tutors are online