+ 1-888-787-5890  
   + 1-302-351-4405  
 
 
 
 

Essay/Term paper: Fractable.cpp

Essay, term paper, research paper:  High School Essays

Free essays available online are good but they will not follow the guidelines of your particular writing assignment. If you need a custom term paper on High School Essays: FracTable.cpp, you can hire a professional writer here to write you a high quality authentic essay. While free essays can be traced by Turnitin (plagiarism detection program), our custom written essays will pass any plagiarism test. Our writing service will save you time and grade.

//FracTable



#include <iostream>

#include <cmath>

#include <conio.h> //required for getch()

#include <iomanip> //required for setw()

using namespace std;



class fraction //fraction class

{

private:

int num,den;

public:



fraction(): num(0),den(0){}



fraction(int n,int d):num(n),den(d) {}



void display() {cout<<num<<"/";cout.setf(ios::left);cout<<setw(4)<<den;}





fraction mult(fraction&, fraction&);



void dispheader()

{cout <<num <<"/";cout.setf(ios::left);cout<<setw(4)<<den;}



void lowterms();



};





//----------------------Source copy from textbook----------------------------





void fraction::lowterms() // Change ourself to lowest terms

{

long tnum, tden, temp, gcd;



tnum = labs(num); // use non-negative copies

tden = labs(den); // (needs cmath)



if(tden == 0) // check for 0/n

{

cout << "Illegal fraction: division by 0"; exit(1);

}

else if(tnum==0) //check for 0/n

{

num = 0; den = 1; return;

}



//This 'while' loop finds the gcd of tnum tden



while(tnum != 0)

{

if(tnum < tden) // ensure numerator larger

{

temp = tnum; tnum = tden; tden = temp; //swam them

}

tnum = tnum - tden; // subtract them

}

gcd = tden; // this is greates comon divisor

num = num / gcd; // divide both num and den by gcd

den = den / gcd; // to reduce frac to lowest terms

}





//-----------------------End of source copy from textbook-------------------



int get_den() //get denominator from user

{



int valid =2;

int denom;

cout<< "Enter a denominator:a ";

cin>>denom; cout<<endl;

if (denom < valid)

do //loop until valid entry

{

cout<< "Invalid entry. Try again."<<endl;

cout<< "Enter a denominator:a " ;

cin>> denom; cout<<endl;

}

while(denom < valid);



return denom;

}

/*----------------------------------------------------------------*/

fraction fraction::mult(fraction& x,fraction& y)

{



fraction temp;



temp.num = x.num * y.num;

temp.den = x.den * y.den;



return temp;

}

/*----------------------------------------------------------------*/

int main()

{



int atemp,btemp,din;

int headmax(8);

int dashmax(7);







din=(get_den());

cout<<setw(headmax)<<" ";





for (atemp=1; atemp < din ; atemp++)

{

fraction x(atemp,din);

x.lowterms();

x.dispheader();



}

cout <<endl;

for (int temp = 1; temp <(din*dashmax); temp++)

{

cout<<"-";

}







for (atemp=1; atemp < din ; atemp++)

{

fraction x(atemp,din);

cout<<endl;



if (atemp < din)

{

x.lowterms();

x.display();

cout<<"| ";

}

for (btemp=1; btemp < din; btemp++)

{

fraction y(btemp,din);



fraction z= z.mult(x,y);



z.lowterms();

z.display();

}





}











cout<< endl<< "Press any key to terminate program.a";

getch(); //keep window open until key pressed



return 0;

}



















 

Other sample model essays:

High School Essays / France's Ecconomy
France is one of the world's richest nations. Industrialization began at the end of the 18th century. Unlike England and the rest of Europe, France failed to maintain the momentum of its early indust...
High School Essays / France
Introduction France, which is the largest nation in Western Europe, is a presidential republic. France is a very important nation in Europe and it continues to be involved in contemporary policy ...
High School Essays / Frank Lloyd Wright
These ideas proposed by Wright represent a half century of ingenuity and unrivaled creativity. Wright was unquestionably a architectural genius and was years ahead of his time. The biggest ...
High School Essays / Freedom Of Expression
COSHE.COM : uncategorized : freedom of expression on the internet freedom of expression on the internet First and foremost, in the United States the freedom of expression is guaranteed...
High School Essays / Freedom VS Destiny
Greg Knott English 12 2-21-00 Freedom VS Predestination People like to believe that they have the freedom to choose what they want to do, however it is quite the opposite. Freedo...
High School Essays / Friendship
When I think about what makes someone a good friend, I think about all the characteristics of my own friends. My personal definition of a friend, is someone who is always looking out for me, ...
High School Essays / F -14 Tomcat
F-14 TOMCAT Wing span: 64 feet unswept; 38 feet swept Length: 62 feet 7 inches Height: 16 feet Weight: Empty: 40,104 pounds Maximum take-off: 74,348 pounds Speed: Maximum: 1,544...
High School Essays / Gender Identity Conflict
In the story "X: A Fabulous Child"s Story," a child is raised as an X. An X is a child who is assigned to a neutral gender by its parents and scientists. The parents of X raise ...
High School Essays / Glass Menagerie
Glass Menagerie: Relationship Between Jim and Laura Essay submitted by Sarah In high school, Jim was basically your all ar...
High School Essays / Goethe Und Gott
"Goethe und Gott" Die Gedichte "Prometheus", "Die Grenzen der Menschheit", and "Das Goettliche" von Johann Wolfgang von Goethe reflektieren die Entwicklung der Ideen d...
Experience with Dream Essay - Reliable and great customer service. Quality of work - High quality of work.
Browns Mills, New Jersey, United States
Dream Essay - Very reliable and great customer service. Encourage other to try their service. Writer 91463 - Provided a well written Annotated Bibliography with great deal of detail per the rubric.
Browns Mills, New Jersey, United States
it is always perfect
Frederick, Maryland, United States
The experience with Dream Essay is stress free. Service is excellent and forms various forms of communication all help with customer service. Dream Essay is customer oriented. Writer 17663 is absolutely excellent. This writer provides the highest quality of work possible.
Browns Mills, New Jersey, United States
Only competent & proven writers
Original writing — no plagiarism
Our papers are never resold or reused, period
Satisfaction guarantee — free unlimited revisions
Client-friendly money back guarantee
Total confidentiality & privacy
Guaranteed deadlines
Live Chat & 24/7 customer support
All academic and professional subjects
All difficulty levels
12pt Times New Roman font, double spaced, 1 inch margins
The fastest turnaround in the industry
Fully documented research — free bibliography guaranteed
Fax (additional info): 866-332-0244
Fax (additional info): 866-308-7123
Live Chat Support
Need order related assistance?—Click here to submit a inquiry
© Dreamessays.com. All Rights Reserved.
Dreamessays.com is the property of MEDIATECH LTD