Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please fix the code c++: (Don't change QT classes) #include #include QTextStream cout(stdout); QTextStream cin(stdin); class Fraction { private : int m_Numberator; int m_Denominator; public

please fix the code c++: (Don't change QT classes)

#include

#include

QTextStream cout(stdout);

QTextStream cin(stdin);

class Fraction {

private:

int m_Numberator;

int m_Denominator;

public:

Fraction() {

set(m_Numberator,m_Denominator);

}

void set(int numerator, int denominator) {

m_Numberator = numerator;

m_Denominator = denominator;

}

Fraction add(Fraction& other) {

Fraction temp;

temp.m_Denominator=m_Denominator+other.m_Denominator;

temp.m_Numberator=m_Numberator+other.m_Denominator;

return temp;

}

Fraction substact(Fraction& other){

Fraction temp;

temp.m_Denominator=m_Denominator-other.m_Denominator;

temp.m_Numberator=m_Numberator-other.m_Denominator;

return temp;

}

Fraction multiply(Fraction& other){

Fraction temp;

temp.m_Denominator=m_Denominator*other.m_Denominator;

temp.m_Numberator=m_Numberator*other.m_Denominator;

return temp;

}

Fraction divide(Fraction& other){

Fraction temp;

temp.m_Denominator= m_Denominator/other.m_Denominator;

temp.m_Numberator=m_Numberator/other.m_Denominator;

return temp;

}

double toDouble() {

return double (m_Denominator);

}

QString toString() {

return QString("This is the numberator This is the Denominator This is divition This is multiply This is substraction This is addition ").arg(m_Numberator).arg(m_Denominator).arg(m_Numberator/m_Denominator).arg(m_Numberator*m_Denominator).arg(m_Numberator-m_Denominator).arg(m_Numberator+m_Denominator);

}

};

int main()

{

Fraction f;

Fraction f2;

Fraction c;

f.set(3, 2);

f2.set(6, 9);

c = f.add(f2);

cout<< f.toString() << endl;

cout<< c.toString() << endl;

}

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

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

=+Show photos of consumers?

Answered: 1 week ago

Question

What is Accounting?

Answered: 1 week ago

Question

Define organisation chart

Answered: 1 week ago

Question

What are the advantages of planning ?

Answered: 1 week ago

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

Are these written ground rules?

Answered: 1 week ago

Question

Have ground rules been established for the team?

Answered: 1 week ago

Question

a. How are members selected to join the team?

Answered: 1 week ago