-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathFraction4123.h
46 lines (35 loc) · 1.01 KB
/
Fraction4123.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include<iostream>
using namespace std;
class Fraction4123
{
private:
int num;
int den;
int gcd(int x, int y); //function to find gcd
public:
//Default constructor sets numerator
//to zero and denominator to 1
Fraction4123();
//Parameterized constructor sets numerator
//and denominator based on parameters passed in
Fraction4123(int n, int d);
// Getters and setters
int getNumerator();
int getDenominator();
void setNumerator(int n);
void setDenominator(int d);
//Function to simplify the fraction to lowest terms
void simplify();
//Member functions that return the answer
//through a return statement
Fraction4123 add(Fraction4123);
Fraction4123 subtract(Fraction4123);
Fraction4123 multiply(Fraction4123);
Fraction4123 divide(Fraction4123);
//Function to return the decimal equivalent of a Fraction
double toDecimal();
friend ostream & operator<<(ostream &out, Fraction4123 f);
//Destructor
~Fraction4123();
};