Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ We're gonna make a rational number library! Take a look at rationals.h-that file contains the declarations for three functions that you will implement in

c++
image text in transcribed
image text in transcribed
We're gonna make a rational number library! Take a look at rationals.h-that file contains the declarations for three functions that you will implement in rationals.cpp. Anyone who wants to use your library wil include your rational.hr Now go to rationals.cpp and start implementing the functions. You should see a GCD function implemented for you already-you'll use that in your rationalSimplify function to simplify the numerator and denominator of a rational number Notice that rationalSimplity and rational Times do not retum anything-rather, they have some reference parameters that will automatically get changed thanks to the magic of call-by-reference. rationalPrettyString returns the string form of a rational number. Remember to give back a string and to not print anything out. I've made a program called sample Program.cpp that will help you test out your solution. Compile it with; 8++ -std=C++17 sampleProgram.cpp rationals.cpp - samplePropran (remember to include rationals.cpp-g++ needs the implementation when it links your program!). Here's what the output should look like given some sample inputs: solution git:(master) x ./sampleProgram Enter first numerator: 2 Enter first denominator: -22 Enter second numerator: 4 Enter second denominator: 8 Simplified first number: -1 / 11 Second number: 1 / 2 First number * Second number: -1 / 22 solution git:(master) X After you've got sample Program.cpp looking mostly correct, it's time to start running the real, hardcore tests in test.cpp. I've made 3 for you. Compile that with: g++ -std-C++17 test.cpp rationals.cpp - test and get it to run. If the tests pass, you should see the following output solution git:(master) X ./test PASSED: Simplify 2/ - 44 PASSED: 2/ -44 * -3/6 PASSED: Pretty 7/-49 solution git:(master) XI We're gonna make a rational number library! Take a look at rationals.h-that file contains the declarations for three functions that you will implement in rationals.cpp. Anyone who wants to use your library will include your rationals.h! Now go to rationais.cpp and start implementing the functions. You should see a GCD function implemented for you already-you'll use that in your rational Simplify function to simplify the numerator and denominator of a rational number. Notice that rationalSimplity and rationalTimes do not return anything-rather they have some reference parameters that will automatically get changed thanks to the magic of call-by-reference rational PrettyString returns the string form of a rational number. Remember to give back a string and to not print anything out I've made a program called sample Program.cpp that will help you test out your solution Compile it with: g++ -stdec++17 Sample Program.cpp rationals.cpp - SampleProgram (remember to include rationals.opp-9++ needs the implementation when it links your program. Here's what the output should look like given some sample inputs: solution git:(master) X ./sample Program Enter first numerator: 2 Enter first denominator: -22 Enter second numerator: 4 Enter second denominator: 8 Simplified first number: -1 / 11 Second number: 1 / 2 First number * Second number: -1 / 22 solution git:(master) X] After you've got sample Program.cpp looking mostly correct, it's time to start running the real hardcore tests in test.cpp I've made 3 for you. Compile that with g++ -std=C++17 test.cpp rationals.cpp - test and get it to run. If the tests pass, you should see the following output solution git:(master) X ./test PASSED: Simplify 2/ -44 PASSED: 2/-44 * -3/6 PASSED: Pretty 77-49 solution git:(master) X| Once those tests pass, it's your tum to write some. We're gonna make a rational number library! Take a look at rationals.h-that file contains the declarations for three functions that you will implement in rationals.cpp. Anyone who wants to use your library wil include your rational.hr Now go to rationals.cpp and start implementing the functions. You should see a GCD function implemented for you already-you'll use that in your rationalSimplify function to simplify the numerator and denominator of a rational number Notice that rationalSimplity and rational Times do not retum anything-rather, they have some reference parameters that will automatically get changed thanks to the magic of call-by-reference. rationalPrettyString returns the string form of a rational number. Remember to give back a string and to not print anything out. I've made a program called sample Program.cpp that will help you test out your solution. Compile it with; 8++ -std=C++17 sampleProgram.cpp rationals.cpp - samplePropran (remember to include rationals.cpp-g++ needs the implementation when it links your program!). Here's what the output should look like given some sample inputs: solution git:(master) x ./sampleProgram Enter first numerator: 2 Enter first denominator: -22 Enter second numerator: 4 Enter second denominator: 8 Simplified first number: -1 / 11 Second number: 1 / 2 First number * Second number: -1 / 22 solution git:(master) X After you've got sample Program.cpp looking mostly correct, it's time to start running the real, hardcore tests in test.cpp. I've made 3 for you. Compile that with: g++ -std-C++17 test.cpp rationals.cpp - test and get it to run. If the tests pass, you should see the following output solution git:(master) X ./test PASSED: Simplify 2/ - 44 PASSED: 2/ -44 * -3/6 PASSED: Pretty 7/-49 solution git:(master) XI We're gonna make a rational number library! Take a look at rationals.h-that file contains the declarations for three functions that you will implement in rationals.cpp. Anyone who wants to use your library will include your rationals.h! Now go to rationais.cpp and start implementing the functions. You should see a GCD function implemented for you already-you'll use that in your rational Simplify function to simplify the numerator and denominator of a rational number. Notice that rationalSimplity and rationalTimes do not return anything-rather they have some reference parameters that will automatically get changed thanks to the magic of call-by-reference rational PrettyString returns the string form of a rational number. Remember to give back a string and to not print anything out I've made a program called sample Program.cpp that will help you test out your solution Compile it with: g++ -stdec++17 Sample Program.cpp rationals.cpp - SampleProgram (remember to include rationals.opp-9++ needs the implementation when it links your program. Here's what the output should look like given some sample inputs: solution git:(master) X ./sample Program Enter first numerator: 2 Enter first denominator: -22 Enter second numerator: 4 Enter second denominator: 8 Simplified first number: -1 / 11 Second number: 1 / 2 First number * Second number: -1 / 22 solution git:(master) X] After you've got sample Program.cpp looking mostly correct, it's time to start running the real hardcore tests in test.cpp I've made 3 for you. Compile that with g++ -std=C++17 test.cpp rationals.cpp - test and get it to run. If the tests pass, you should see the following output solution git:(master) X ./test PASSED: Simplify 2/ -44 PASSED: 2/-44 * -3/6 PASSED: Pretty 77-49 solution git:(master) X| Once those tests pass, it's your tum to write some

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

More Books

Students also viewed these Databases questions

Question

4 Outline the advantages and disadvantages of equity financing

Answered: 1 week ago

Question

What must a creditor do to become a secured party?

Answered: 1 week ago

Question

When should the last word in a title be capitalized?

Answered: 1 week ago