computer science: c++ (QT) Hw

#include <iostream>

using namespace std;

int main(int argc, char *argv[])

int num1, denom1;

char junk;

cout<<"Please enter your first fraction: ";

cin>>num1>>junk>>denom1;

cout<<"You entered: "<<num1<<"/"<<denom1<<endl;

return 0;

#include <iostream> //All console input and output

#include <cmath> //Trig, sqrt, etc

#include <cstdlib> //Used for system(), abs, etc

using namespace std;

int main(int argc, char *argv[])

double degC, degF;

char answer;

do

{

cout<<"Please enter the temperature in degrees Centigrade: ";

cin>>degC;

degF = 9./5.*degC + 32;

cout<<degC<<" degrees Centigrade is "

<<degF

<<" degrees Farenheit"

<<endl<<endl

<<"Do you want to do this again? ";

cin>>answer;

}while(answer == 'Y' || answer == 'y');

return 0;

#include <iostream>

#include <cmath>

using namespace std;

/*

* This program will solve the quadratic equation.

*

* Written on March 20, 2017

* by

* Someone

*

*/

int main(int argc, char *argv[])

double a, b, c, det, minusBover2a;

char answer;

do

{

cout<<"Please enter the coefficients of your quadratic: ";

cin>>a>>b>>c;

minusBover2a = -b/(2*a);

det = b*b - 4 * a * c;

// det = pow(b,2.) - 4 * a * c;

if(det < 0) //Imaginary Roots

{

det *= -1; //det = det * - 1;

cout<<"x = ";

if(minusBover2a != 0) //If with no else

cout<<minusBover2a<<" ";

cout<<"+/- "<<sqrt(det)/(2*a)<<"i"<<endl;

}

else //another if... also called ladder-if

if(det == 0) //One real root

cout<<"x = "<<minusBover2a<<endl;

else //Two real roots

{

double x1 = minusBover2a + sqrt(det)/(2*a),

x2 = minusBover2a - sqrt(det)/(2*a);

cout<<"x = "<<x1<<" or "<<x2<<endl;

}

cout<<endl<<"Do you want to do this again? ";

cin>>answer;

}while(answer == 'Y' || answer == 'y');//Post test loop

return 0;

#include <iostream>

using namespace std;

int main(int argc, char *argv[])

int first, second;

cout<<"Please enter two integers, seperated by a space: ";

cin>>first>>second;

if(first > second)

cout<<first<<" is greater than "<<second<<endl;

else

if(first == second)

cout<<"you entered the same number twice!"<<endl;

else

cout<<second<<" is greater than "<<first<<endl;

return 0;