Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include #include fractionType.h using namespace std; int main() { fractionType num1(5, 6); //Line 1 fractionType num2; //Line 2 fractionType num3; //Line 3 cout cout
#include
#include
#include "fractionType.h"
using namespace std;
int main()
{
fractionType num1(5, 6); //Line 1
fractionType num2; //Line 2
fractionType num3; //Line 3
cout
cout
cout
cout
cout
cout
cin >> num2; //Line 10
cout
cout
//Line 12
num3 = num1 + num2; //Line 13
cout
cout
cout
num3 = num1 - num2; //Line 17
cout
cout
cout
cout
cout
cout = ("
= num2)
cout
cout ("
num2)
cout
(30 marks Task-1: Rational fractions are of the orm a/b, in which a and b are integers and b * a la this cuaase, by fractions" we mean rational fractions. Suppose a /b and c/d are fractions. Arithmetic operatioes and selational operations on fractions are definod by the following nules: Arithmetic Operations: labifeld) adbe, in which eld 0 Relational Operations: Fractions are compared as follows: albope dif ad op be, in which op is any of the relational operations For example, albce/d if adbe. In this assignment, you will need to design a class -say, fractiontype which performs the arithmetic and relational operations on fractions. Overload the arithmetic and relationa opcrators so that the appropriatc symbols can be used to perform the opcration. Also, overload the strcam insertion and stream extraction opcratoes for easy input and output. Write a C+ program that using the class EractionType, performs operations on fractions. Among other things, test the following: Suppose x, y, and z are objects of type fraction Type. If the inpet is 23, the statement: cin >>should store 2/3 in x The statement; cout return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started