jbo214hw2p6 - }...

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

View Full Document Right Arrow Icon
/* **************************************** Joshua Okrent 819710517 9/21/2010 HW # 2 Khadija Benjilali Section 12 **************************************** */ using namespace std; #include<iostream> #include<cmath> int main() { double xi, xf, increment, c, x, s, l, sc, negative, tx=0, tc=0, ts=0, tl=0; cout<<"Please enter a value between 0 and 2 for xi followed by a value for xf."<<endl; cin>>xi>>xf; while (2<xi || xi<0 || 2<xf || xi<0) { cout<<"You entered an invalid number. Please try again. "<<endl; cin>>xi>>xf;
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } cout&lt;&lt;&quot;\nX &quot;&lt;&lt;&quot;cos(3x) &quot;&lt;&lt;&quot;sin3x &quot;&lt;&lt;&quot;ln(x) &quot;&lt;&lt;endl&lt;&lt;endl; increment=(xf-xi)/4.; for(x=xi; x&lt;=xf; x+increment) { c=cos(3*x); s=sin(3*x); l=log(x); if(c&gt;=0) tc+=c; if(s&gt;=0) ts+=s; if(l&gt;=0) tl+=l; cout&lt;&lt;x&lt;&lt;&quot; &quot;; if(c&gt;=0) cout&lt;&lt;c&lt;&lt;&quot; &quot;; else cout&lt;&lt;&quot;negative &quot;; if(s&gt;=0) cout&lt;&lt;s&lt;&lt;&quot; &quot;; else cout&lt;&lt;&quot;negative &quot;; if(l&gt;=0) cout&lt;&lt;l&lt;&lt;&quot; &quot;&lt;&lt;endl; else cout&lt;&lt;&quot;negative &quot;&lt;&lt;endl; x+=increment; } cout&lt;&lt;&quot;\nSum &quot;&lt;&lt;tc&lt;&lt;&quot; &quot;&lt;&lt;ts&lt;&lt;&quot; &quot;&lt;&lt;tl&lt;&lt;&quot; &quot;&lt;&lt;endl&lt;&lt;endl&lt;&lt;endl; system(&quot;pause&quot;); return 0; }...
View Full Document

Page1 / 2

jbo214hw2p6 - }...

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

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