Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is my process, can you complete? Lab 5 Due Date: See Blackboard Source File: /2336/05/1ab05. (CICPPl cpplc++cclcxxl cp) Input: Output: Value: Under control of

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

this is my process, can you complete?

image text in transcribed

Lab 5 Due Date: See Blackboard Source File: /2336/05/1ab05. (CICPPl cpplc++cclcxxl cp) Input: Output: Value: Under control of main function Under control of main function Extend the Rational class from Labs 02 and 03 to provide the following additional member functions: Functions to implement the equality operators; that is, develop functions for equality and inequality Functions to implement the various relational operators; that is, develop functions for , and 2 It is only necessary to write code for one of the equality operators and one of the relational operators. Once these two functions are written, the remaining four functions are then written in terms of the original two functions. It is traditional to write the code for equality and<. construct this assignment in fashion a header file is shown figure sample main function for testing your implementation and execution sequence to use the makefile as distributed class add target of lab05 targets2srcfileswithlibrary lab05-h> susing namespace std; s class Rational 1o public: RationalO // default constructor // additional constructor // set numerator to num // set denominator to denom // returns numerator // returns denominator // Reduce to 1owest terms // and normalize // Addition // Returns the additive // inverse 12 Rational(int num, int denom); 13 void setNumerator(int num); 1 void setDenominator int denom); us int getNumerator) const; 16int getDenominator) const; void reduce: 19 Rational add (const Rational& addend) const; 20 Rational additiveInverse const 22 Rational subtract (const Rational& subtrahend) const; /I Subtraction 2 Rational multiply (const Rational& multiplicand) const; // Multiplication 2 Rational multiplicativeInverse) const; // Returns the /multiplicative inverse 26 Rational divide(const Rational&divisor) const; 2ostream& print(ostream& os) const; Division // Print Rational to output // stream // Read Rational from input istream& read (istream& is); stream Figure 1. /usr/local/2336/include/lab05.h (Part 1 of 2) Lab 5 Due Date: See Blackboard SIbool isEqualTo (const Rationalk other) const *thisother 32bool isNotEqualTo (const Rational& other) const; //*this other bool isLessThan (const Rational& other) const; /I *thisother bool isLessThanOrEqualTo (const Rational& other) const; // thisother s bool isGreaterThan(const Rational other) const; // *this > other bool isGreaterThanOrEqualTo (const Rational& other) const; I/ *this other 7 private // r[o] represents numerator // r[1] represents denominator // returns the greatest /common divisor of m // and n // returns the least common // multiple of m and n int r[2]; int gcd(int m, int n) const; 43int lcm(int m, int n) const; 47 #endif Figure 1. /usr/local/2336/include/1ab05.h (Part 2 of 2) 1 #include z #include #include susing namespace std; int mainO Rational first(1, -2), second (-3, 0), result; 1 cout cd 2336 nevuserdcsunix /2336>/getlab.ksh 05 * Checking to see if a folder exist8 for Lab OSNo Creating a folder for Lab 05 Checking to see if Lab 0 has sample input and output files. .Yes 6Copying input and output files for Lab 05 from folder /usr/local/2336/data/05 to folder ./05 Checking to see if /uar/local/2336/arc/lab05main.c exists. . .Yea Copying file /uar/local/2336/src/lab05main.C to folder ./05 Checking to see if /usr/local/2336/include/1abo5.h exists. . .Yes 11 Copying file /uar/local/2336/include/lab05.h to folder -/05 12 Copying file /usr/local/2336/arc/Makefile to folder /05 * Adding a target of lab05 to targets2srcfileswithlibrary Touching file ./05/1abo5.cpp usEdit file ./05/lab05.cpp in Notepadtt 16 newuserdcsunix /2336> cd 05 17 newuserdcsunix /2336/05> ls 1s 01.dat 01.out laboS.cpp lab05.h lab05main.C Figure 3. Commands to Compile, Link,&Run Lab 05 (Part 1 of 2) CS 2336Data Structures and Algorithms Page 3 s gtt -8 -Wall -std-c++11- lab05main.c -I/uar/local/2336/include -I 20 gtt -g-Wall -atd-c++11 -c lab05.cpp -I/uar/local/2336/include -1 21 gt -o lab05 lab05main.o lab05.o -L/usr/local/2336/1ib 22 -Wl,-whole-archive 1lab05-wl,-no-vhole-archive 1m -1bits 23 newuser@csunix "/2336/05> cat 01.dat 24 -3 4 3 4 25 3-4-3-4 26 25 45 8 99 27 1 0 2 0 2 129 6579 1935 249 2 1331 1651 2301 1079 30 3 1260 6 198 1 43 1935 207 6579 63 129/6579 1935/249false 66 129/6579 1935/249false 67 1331/1651=2301/1079= false 6s 1331/1651 2301/1079true 69 1331/1651 2301/1079-false 72 1331/16512301/1079-false 7a 3/12606/198 false 74 3/1260- 6/198 true 7 3/12606/198 true 76 3/12606/198 true 77 3/1260> 6/198= false 7 3/1260 6/198 false 79 43/1935 207/6579 false so 43/1935! 207/6579true 1 43/1935207/6579true 82 43/ 1935 207/6579= true sa 43/ 1935 > 207/6579= false 4 43/1935 207/6579 false ss 5/7-25/-35 true s 5/7-25/-35 false 67 5/7--25/-35 true 91 -83/1651 127/-1079 false 92-83/1651 != 127/-1079= true 9-83/1651 127/-1079 false 94-83/1651 127/-1079 true 96 -83/1651- 127/-1079 true 97 1079/ 1651 1651/1079= false 9 1079/1651 -1651/1079 -true 99 1079/1651 1651/1079 -false 100 1079/1651 1651/1079-true 102 1079/1651 1651/1079-true -83 1651 127-1079 4 1079 1651-1651 1079 as newuser@csunix /2336/05> cat 01.dat I /lab05 -3/43/4-false 39 -3/4=-3/-4 = false 49 25/458/99 false s0 25/45-8/99 true 51 25/45 8/99= true 4 25/458/99 true ss 1/1 2/1 - false 56 1/12/1-true S7 1/12/1-true 59 1/1 2/1 false so 1/1 2/1 - false 61 129/6579.-1935/249= false 62 129/6579 - 1935/249 true newuser csunix /2336/05> cat 01.dat I ./lab05 my.out 0 newuserecsunix /2336/05> diff 01.out my.out 105 newuser@csunix/2336/05> Figure 3. Commands to Compile, Link, &Run Lab 05 (Part 2 of 2) CS 2336Data Structures and Algorithms #include bool Rational :: stqualTo(const Rational& other) const // *this-other return this->subtract(other).getNumerator)0; bool Rational: :isNotEqualTo(const Rational& other) const; // *this - other //return this->subtract (other).getNumerator)-0;/ot recommend return this->isEqualTo(other); bool Rational::isLessThan(const Rational& other) const; // *this = other Lab 5 Due Date: See Blackboard Source File: /2336/05/1ab05. (CICPPl cpplc++cclcxxl cp) Input: Output: Value: Under control of main function Under control of main function Extend the Rational class from Labs 02 and 03 to provide the following additional member functions: Functions to implement the equality operators; that is, develop functions for equality and inequality Functions to implement the various relational operators; that is, develop functions for , and 2 It is only necessary to write code for one of the equality operators and one of the relational operators. Once these two functions are written, the remaining four functions are then written in terms of the original two functions. It is traditional to write the code for equality and<. construct this assignment in fashion a header file is shown figure sample main function for testing your implementation and execution sequence to use the makefile as distributed class add target of lab05 targets2srcfileswithlibrary lab05-h> susing namespace std; s class Rational 1o public: RationalO // default constructor // additional constructor // set numerator to num // set denominator to denom // returns numerator // returns denominator // Reduce to 1owest terms // and normalize // Addition // Returns the additive // inverse 12 Rational(int num, int denom); 13 void setNumerator(int num); 1 void setDenominator int denom); us int getNumerator) const; 16int getDenominator) const; void reduce: 19 Rational add (const Rational& addend) const; 20 Rational additiveInverse const 22 Rational subtract (const Rational& subtrahend) const; /I Subtraction 2 Rational multiply (const Rational& multiplicand) const; // Multiplication 2 Rational multiplicativeInverse) const; // Returns the /multiplicative inverse 26 Rational divide(const Rational&divisor) const; 2ostream& print(ostream& os) const; Division // Print Rational to output // stream // Read Rational from input istream& read (istream& is); stream Figure 1. /usr/local/2336/include/lab05.h (Part 1 of 2) Lab 5 Due Date: See Blackboard SIbool isEqualTo (const Rationalk other) const *thisother 32bool isNotEqualTo (const Rational& other) const; //*this other bool isLessThan (const Rational& other) const; /I *thisother bool isLessThanOrEqualTo (const Rational& other) const; // thisother s bool isGreaterThan(const Rational other) const; // *this > other bool isGreaterThanOrEqualTo (const Rational& other) const; I/ *this other 7 private // r[o] represents numerator // r[1] represents denominator // returns the greatest /common divisor of m // and n // returns the least common // multiple of m and n int r[2]; int gcd(int m, int n) const; 43int lcm(int m, int n) const; 47 #endif Figure 1. /usr/local/2336/include/1ab05.h (Part 2 of 2) 1 #include z #include #include susing namespace std; int mainO Rational first(1, -2), second (-3, 0), result; 1 cout cd 2336 nevuserdcsunix /2336>/getlab.ksh 05 * Checking to see if a folder exist8 for Lab OSNo Creating a folder for Lab 05 Checking to see if Lab 0 has sample input and output files. .Yes 6Copying input and output files for Lab 05 from folder /usr/local/2336/data/05 to folder ./05 Checking to see if /uar/local/2336/arc/lab05main.c exists. . .Yea Copying file /uar/local/2336/src/lab05main.C to folder ./05 Checking to see if /usr/local/2336/include/1abo5.h exists. . .Yes 11 Copying file /uar/local/2336/include/lab05.h to folder -/05 12 Copying file /usr/local/2336/arc/Makefile to folder /05 * Adding a target of lab05 to targets2srcfileswithlibrary Touching file ./05/1abo5.cpp usEdit file ./05/lab05.cpp in Notepadtt 16 newuserdcsunix /2336> cd 05 17 newuserdcsunix /2336/05> ls 1s 01.dat 01.out laboS.cpp lab05.h lab05main.C Figure 3. Commands to Compile, Link,&Run Lab 05 (Part 1 of 2) CS 2336Data Structures and Algorithms Page 3 s gtt -8 -Wall -std-c++11- lab05main.c -I/uar/local/2336/include -I 20 gtt -g-Wall -atd-c++11 -c lab05.cpp -I/uar/local/2336/include -1 21 gt -o lab05 lab05main.o lab05.o -L/usr/local/2336/1ib 22 -Wl,-whole-archive 1lab05-wl,-no-vhole-archive 1m -1bits 23 newuser@csunix "/2336/05> cat 01.dat 24 -3 4 3 4 25 3-4-3-4 26 25 45 8 99 27 1 0 2 0 2 129 6579 1935 249 2 1331 1651 2301 1079 30 3 1260 6 198 1 43 1935 207 6579 63 129/6579 1935/249false 66 129/6579 1935/249false 67 1331/1651=2301/1079= false 6s 1331/1651 2301/1079true 69 1331/1651 2301/1079-false 72 1331/16512301/1079-false 7a 3/12606/198 false 74 3/1260- 6/198 true 7 3/12606/198 true 76 3/12606/198 true 77 3/1260> 6/198= false 7 3/1260 6/198 false 79 43/1935 207/6579 false so 43/1935! 207/6579true 1 43/1935207/6579true 82 43/ 1935 207/6579= true sa 43/ 1935 > 207/6579= false 4 43/1935 207/6579 false ss 5/7-25/-35 true s 5/7-25/-35 false 67 5/7--25/-35 true 91 -83/1651 127/-1079 false 92-83/1651 != 127/-1079= true 9-83/1651 127/-1079 false 94-83/1651 127/-1079 true 96 -83/1651- 127/-1079 true 97 1079/ 1651 1651/1079= false 9 1079/1651 -1651/1079 -true 99 1079/1651 1651/1079 -false 100 1079/1651 1651/1079-true 102 1079/1651 1651/1079-true -83 1651 127-1079 4 1079 1651-1651 1079 as newuser@csunix /2336/05> cat 01.dat I /lab05 -3/43/4-false 39 -3/4=-3/-4 = false 49 25/458/99 false s0 25/45-8/99 true 51 25/45 8/99= true 4 25/458/99 true ss 1/1 2/1 - false 56 1/12/1-true S7 1/12/1-true 59 1/1 2/1 false so 1/1 2/1 - false 61 129/6579.-1935/249= false 62 129/6579 - 1935/249 true newuser csunix /2336/05> cat 01.dat I ./lab05 my.out 0 newuserecsunix /2336/05> diff 01.out my.out 105 newuser@csunix/2336/05> Figure 3. Commands to Compile, Link, &Run Lab 05 (Part 2 of 2) CS 2336Data Structures and Algorithms #include bool Rational :: stqualTo(const Rational& other) const // *this-other return this->subtract(other).getNumerator)0; bool Rational: :isNotEqualTo(const Rational& other) const; // *this - other //return this->subtract (other).getNumerator)-0;/ot recommend return this->isEqualTo(other); bool Rational::isLessThan(const Rational& other) const; // *this = other

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

Review behavior therapy techniques based on operant conditioning.

Answered: 1 week ago

Question

To identify HRM functions when it is created.

Answered: 1 week ago

Question

To understand the role of HRM as a business development partner.

Answered: 1 week ago