-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask1_main.cpp
85 lines (68 loc) · 2.01 KB
/
Task1_main.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* @file Task1_main.cpp
*
* @brief This code implements rational numbers in C++.
*
* @author Saif Ullah Ijaz
*
*/
// SYSTEM INCLUDES
#include <iostream>
using namespace std;
// LOCAL INCLUDES
#include "Rational.h"
// function main begins program execution
void main() {
Rational aRational(220, 18), bRational(1080, 66);
cout << "First Rational Number:" << endl;
cout << "Rational Form: ";
aRational.PrintFraction();
cout << endl;
cout << "Floating-point Form: ";
aRational.PrintFloat();
cout << endl << endl;
cout << "Second Rational Number:" << endl;
cout << "Rational Form: ";
bRational.PrintFraction();
cout << endl;
cout << "Floating-point Form: ";
bRational.PrintFloat();
cout << endl << endl;
Rational rAddition = aRational.AddRational(bRational);
cout << "Addition:" << endl;
cout << "Rational Form: ";
rAddition.PrintFraction();
cout << endl;
cout << "Floating-point Form: ";
rAddition.PrintFloat();
cout << endl << endl;
aRational.SetRational(220, 18), bRational.SetRational(1080, 66);
Rational rSubtraction = aRational.SubtractRational(bRational);
cout << "Subtraction:" << endl;
cout << "Rational Form: ";
rSubtraction.PrintFraction();
cout << endl;
cout << "Floating-point Form: ";
rSubtraction.PrintFloat();
cout << endl << endl;
aRational.SetRational(220, 18), bRational.SetRational(1080, 66);
Rational rMultiplication = aRational.MultiplyRational(bRational);
cout << "Multiplication:" << endl;
cout << "Rational Form: ";
rMultiplication.PrintFraction();
cout << endl;
cout << "Floating-point Form: ";
rMultiplication.PrintFloat();
cout << endl << endl;
aRational.SetRational(220, 18), bRational.SetRational(1080, 66);
Rational rDivision = aRational.DivideRational(bRational);
cout << "Division:" << endl;
cout << "Rational Form: ";
rDivision.PrintFraction();
cout << endl;
cout << "Floating-point Form: ";
rDivision.PrintFloat();
cout << endl << endl;
system("pause");
}
// end main