Lee_assig17 - } if (choice==2) {

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 Assign 17 #include <iostream> #include <cmath> using namespace std double rootQuadraticfunction(double, double, double, double) int gcf(int, int, int) void rightTriangle(int) int main() { int choice=0, x, y, z, base double a, b, c while (choice!=4){ cout<<"What would you like to do? choose 1, 2, 3 or 4:\n" cout<<"+-----------------------------------------------+\n" cout<<"| 1. Calculating roots of a Quadratic Function |\n" cout<<"| 2. Calculating the GCF of three intergers |\n" cout<<"| 3. Display a Right Triangle with asterisks |\n" cout<<"| 4. Exit |\n" cout<<"+-----------------------------------------------+\n" cin>>choice if (choice==1){ cout<<"The Quadratic Function Program"<<endl cout<<"Enter value for a: "<<endl cin>>a cout<<"Enter value for b: "<<endl cin>>b cout<<"Enter value for c: "<<endl cin>>c double pZero, mZero pZero=rootQuadraticfunction(a, b, c, 1) mZero=rootQuadraticfunction(a, b, c, -1) cout<<"Plus Zero: "<<pZero<<endl cout<<"Minus Zero: "<<mZero<<endl
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: } if (choice==2) { cout&amp;lt;&amp;lt;&amp;quot;Enter three intergers and the GCF will be calculated.&amp;quot;&amp;lt;&amp;lt;endl cin&amp;gt;&amp;gt;x&amp;gt;&amp;gt;y&amp;gt;&amp;gt;z cout&amp;lt;&amp;lt;&amp;quot;The GCF is: &amp;quot;&amp;lt;&amp;lt;gcf(x,y,z)&amp;lt;&amp;lt;endl } if (choice==3) { cout&amp;lt;&amp;lt;&amp;quot;You have chosen the Right Triangle program&amp;quot;&amp;lt;&amp;lt;endl cout&amp;lt;&amp;lt;&amp;quot;Enter the base&amp;quot;&amp;lt;&amp;lt;endl cin&amp;gt;&amp;gt;base cout&amp;lt;&amp;lt;&amp;quot;Here is the right triangle: &amp;quot;&amp;lt;&amp;lt;base&amp;lt;&amp;lt;endl rightTriangle(base) } if (choice==4) { cout&amp;lt;&amp;lt;&amp;quot;You have exited the program&amp;quot;&amp;lt;&amp;lt;endl Sheet1 Page 2 if(choice&amp;lt;0||choice&amp;gt;4) cout&amp;lt;&amp;lt;&amp;quot;Invalid Input&amp;quot;&amp;lt;&amp;lt;endl } } return 0 } double rootQuadraticfunction(double p, double q, double r, double s) { double formula = (-q + s * sqrt (q*q-4*p*r))/(2*p) return formula r } int gcf(int a, int b, int c){ int l, m, n, cf for (int i=1 i&amp;lt;=a i++){ for (int j=1 j&amp;lt;=b j++) for (int k=1 k&amp;lt;=c k++){ if(a%i==0) l=i if(b%j==0) m=j if(c%i==0) n=i if(l==m&amp;amp;&amp;amp;l==n) cf=l } } return cf } void rightTriangle(int v) { for(int i=1 i&amp;lt;v i++){ for (int j=1 j&amp;lt;i j++) cout&amp;lt;&amp;lt;&amp;quot;* &amp;quot;&amp;lt;&amp;lt;&amp;quot; &amp;quot; cout&amp;lt;&amp;lt;endl } }...
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_assig17 - } if (choice==2) {

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