Programming Concepts cin/cout variables/types Functions Reference structs Task Summary: For this first Quest you I have…
Programming Concepts

cin/cout

variables/types

Functions

Reference

structs
Task Summary:
For this first Quest you I have set up a program in
Visual Studio that will use operation between fractions. I have
written a basic code example that does all the resources that you
need to follow. Your job is to complete the exercises presented
below in quest2.cpp.
For this assignment you will learn and demonstrate how
to:

Work with functions

use PastbyValue and PastbyReference.

use structs.

use cin to get user input from the keyboard

use Header/Object Files.
Base Code Functionality
The instructor has provided all the
necessary

base main source code (quest2.cpp),
Required Code Functionality
This program will allow basic operations between
fractions, for example, addition, subtraction, multiplication,
division and other basic functions that can be performed in
fractions.To achieve a seamless integration of the struct fraction
into the C++ type system its operations need to be overloaded and
you are required to provide such implementation.
Your task is to implement code
that:

Create a fraction [50 points] //
(implemented) 
Implement the Add two fractions [50 points]
//(implemented) 
Implement the Add fraction and integer [50 points]
//(overload function) 
Implement the negation operator for fractions. [50
points] 
Implement support for division operations for the new
fraction type [100 points] 
Implement Multiply fractions [50 points]

Implement Subtract fraction [100 points]

Implement rational::reduce, which will be used to reduce
fractions. [100 points]
Follow guidelines in your code. [50 points]
Finally, separate the struct definition with method
declarations and function declarations (in a header file), the
function and method definitions (in a source file) and the main
function in the quest2.cpp file. [100 points].
Note: Use test cases to ensure they actually do work.
Create a Test for every function that you implemented.
Task 0: Create project
You will create a project in visual studio that contain
the following files:

quest2.cpp,

rationals.cpp,

rationals.h
The quest2.cpp file contains the int main function. The
rationals.cpp and rational.h files contain the functions required
in the program. The rationals.h file contain the structs and
constants you will be using for your program.
Task 1: Test that your code runs
After you create your program, add the next base code to
your quest2.cpp
#include <iostream>
using namespace std;
struct Fraction {
int numerator_;
int denominator_;
};
Fraction newFraction() {
Fraction f;
f.numerator_ = 1;
f.denominator_ = 2;
return f;
}
Fraction newFraction(int num, int den) {
Fraction f;
f.numerator_ = num;
f.denominator_ = den;
return f;
}
//Examples input and output
//Input > (1\2)+(1/2)
//Output > (4/4)
void addToFraction(Fraction& f1, const Fraction&
f2) {
int denominador =
f1.denominator_*f2.denominator_;
Fraction tmp_lhs =
newFraction(f1.numerator_*f2.denominator_,
denominador);
Fraction tmp_rhs =
newFraction(f2.numerator_*f1.denominator_,
denominador);
f1.numerator_ = tmp_lhs.numerator_ +
tmp_rhs.numerator_;
f1.denominator_ = denominador;
}
//Examples input and output
//Input > (1\2)+2
//Output > (5/2)
void addToFraction(Fraction& f1, int number)
{
}
void printFraction(Fraction& f) {
cout<< ‘(‘ << f.numerator_ << “https://zuoti.pro/”
<< f.denominator_ << ‘)’ << endl;
}
int main() {
//Creating fraction a and b
Fraction a = newFraction(3,2);
Fraction b = newFraction(4,2);
//Printing fraction a and b
printFraction(a);
printFraction(b);
//Adding two fractions
addToFraction(a,b);
printFraction(a);
//Adding fraction to number
addToFraction(a, 12);
cin.get();
return 0;
}
Then, when you compile and run the program, a test
example of add operation is provided, make sure that is working
properly.
Task 2: Complete the program

Create a function for each operation between fraction
required. 
In the main function, you need to create test for every
operation that is required.
Task 3: Record your results
Now you want to make a video where you present how each
function works. Run each test separately. Every operation that is
not presented in the video will not receive points.
Task 4: Submit Completed Assignment
Create a zip file that include your visual studio
project and a 5 minute video explaining your results in
Blackboard!