Lee_assig21 - cout...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 //Cheu Lee Assig 21 #include <iostream> #include <cmath> using namespace std int main() { int a=0 while (a !=3) { int choice cout <<"+----------------------------------------------------------+"<<endl cout <<"| 1. Curving 15 test scores |"<<endl cout <<"| 2. Find the standard deviation |"<<endl cout <<"| 3. Exit |"<<endl cout <<"+----------------------------------------------------------+"<<endl cout <<"Plese make a selection, 1, 2, 3: " cin >>choice if (choice !=3) { switch (choice) { case 1: { double scores[15]={0}, max=scores[0] cout <<endl<<"Please enter five scores: "<<endl for (int i=0 i<15 i++) { cin >>scores[i] if (scores[i]>max) max=scores[i] m } cout.setf (ios::fixed) cout.precision (0)
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;endl&lt;&lt;&quot;The new scores are: &quot; for (int k=0 k&lt;15 k++) { scores[k]=(scores[k]/max)*100 cout &lt;&lt;scores[k]&lt;&lt;&quot; &quot; } cout &lt;&lt;endl&lt;&lt;endl break } case 2: { double num[5]={0}, sum=num[0], mean int n=0 cout &lt;&lt;endl&lt;&lt;&quot;Enter 5 consecutive numbers: &quot;&lt;&lt;endl for (int i=0 i&lt;5 i++) { cin &gt;&gt;num[i] sum+=num[i] Sheet1 Page 2 n+=1 } mean=sum/n double d=0 for (int k=0 k&lt;n k++) { d+=(num[k]-mean)*(num[k]-mean) } double c=d/((n-1)*0.1) double e=sqrt(c) cout &lt;&lt;&quot;Standard deviation is: &quot;&lt;&lt;e&lt;&lt;endl break } } } if (choice&lt;1 || choice&gt;3) cout &lt;&lt;endl&lt;&lt;&quot;Invalid input.&quot;&lt;&lt;endl&lt;&lt;endl if (choice==3) a=choice } cout &lt;&lt;endl&lt;&lt;&quot;Program existed.&quot;&lt;&lt;endl&lt;&lt;endl return 0 }...
View Full Document

This note was uploaded on 05/16/2010 for the course CISCO EST61 taught by Professor Miller during the Spring '10 term at Fresno City College.

Page1 / 2

Lee_assig21 - cout...

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