Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please note , you are required to include the following when you use g++ to compile: -pedantic For example: g++ -pedantic filename.cpp This will give

Please note, you are required to include the following when you use g++ to compile: -pedantic

For example:

g++ -pedantic filename.cpp

This will give a warning if you attempt to use any non-standard feature in g++. You must correct your code so that you do not receive any warnings of this type.

  1. Log on to the Linux server.
  2. Create four files:
  1. Rational.h
  2. Rational.cpp
  3. RationalMain.cpp
  4. Makefile
  1. In Rational.h:

#ifndef _RATIONAL_H_

#define _RATIONAL_H_

#include

using namespace std;

class Rational

{

int _p;

int _q;

public:

Rational();

Rational(int P, int Q = 1);

void display() const; // _p:_q

void add(const Rational&);

void sub(const Rational&);

void mult(const Rational&);

void div(const Rational&);

};

#endif

In Rational.cpp, implement these member functions. You must make sure that you never have

_q zero[1]. Your Rational number must be stored in reduced form, that is, _p and _q must be relatively prime.

You must not use any built-in functions

In RationalMain.cpp, write a test main to test your code.

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

What were your most important educational experiences?

Answered: 1 week ago

Question

Which personal relationships influenced you the most?

Answered: 1 week ago