-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrationalNumberClient.cpp
More file actions
76 lines (63 loc) · 2.24 KB
/
rationalNumberClient.cpp
File metadata and controls
76 lines (63 loc) · 2.24 KB
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
/********************************************
Template created by Kazumi Slott
CS211
Date: 2/18/2022
Your name: Tuan Tran
Description of your program: This program will add, sort and simplify rational numbers
********************************************/
#include <iostream>
using namespace std;
#include "array.h" //This is your array.h
#include "rationalNumber.h"//?????????
int main()
{
rNum n1;
rNum n2;
rNum n3;
rNum ans;
cout << "\n-------------- 1 -----------------" << endl;
cout << "Rational Number 1:" << endl;
cin >> n1;
cout << "n1 is " << n1 << endl;
cout << "\n-------------- 2 -----------------" << endl;
cout << "\nRational Number 2" << endl;
cin >> n2;
cout << "n2 is " << n2 << endl;
cout << "\n-------------- 3 -----------------" << endl;
ans = n1 + n2;
ans.simplify(); //simplifies the answer
cout << n1 << " + " << n2 << " = " << ans << endl;
cout << "\n-------------- 4 -----------------" << endl;
const int SIZE = 3;
//Declare an array of rNums that has SIZE slots
rNum array[SIZE];
//fill the array by calling fill() in your array.h
fill(array, SIZE);
cout << "Checking to see if the array is filled" << endl;
//print the array by calling print() in your array.h
print(array, SIZE);
cout << "\n-------------- 5 -----------------" << endl;
//sort the array in ascending order by calling sort() in your array.h
sort(array, SIZE);
cout << "Checking to see if the array is sorted in ascending order" << endl;
//print the array by calling print() in your array.h
print(array, SIZE);
cout << "\n-------------- 6 -----------------" << endl;
cout << "Checking to see if " << n1 << " is in the array " << endl;
//Call find() in your array.h to see if n1 exists in the array. Say found or not found. See #6 in the test runs in the hw document.
int finder = find(array, SIZE, n1);
if(finder == true) //if it is found
{
cout << n1 << " is found";
}
else //if not found
{
cout << n1 << " is not found";
}
cout << "\n-------------- 7 -----------------" << endl;
cout << "n1 is " << n1 << " n2 is " << n2 << " before n1 += n2" << endl;
n1 += n2;
n1.simplify(); //simplifies n1
cout << "After n1 += n2, n1 is " << n1 << endl << endl;
return 0;
}