Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is a code written in C++. Please fix the program according to the instruction given below. Please don't copy and paste similar answer from

Here is a code written in C++. Please fix the program according to the instruction given below. Please don't copy and paste similar answer from the CHEGG ARCHIVE. Those answers found in the Chegg archive are not the method I am looking for. Back to my question, I have a problem to show an output that is exactly the same as the sample output given below. Please, check the code if it has applied each and every instruction given in the question. I realized that some of the operations are reversed in order. To help you fix the program I highlighted some of the issues I am facing in my original code. Can you make sure all of the highlighted lines are displayed the same way they are displayed in the sample output? Please do the necessary change that this program may need so that it looks exactly like the sample output. I am expecting to get a full credit for this assignment so put your effort to correct and help the program have the most efficient algorithm within the scope of the instruction given.

INSTRUCTIONS

Create a fraction class and add your Name to the name fraction and use this as your class. For Example, if your name is Mark John, then your class name should be FractionMarkJ.

Create a constructor for your fraction class to handle the initialization appropriately.

There will be ONLY one constructor with two arguments.

The constructor should have code to confirm the call/use of itself through the printing (e.g. Calling Fraction ( int, int ) ) and continue with the display of numerator and denominator after being initialized/built.

There will be a member function print ( ) that will print the current Fraction object.

There will be a member function extractUncommonDigit ( ) that will return an array of common digits between the numerator and denominator.

IMPORTANT REMAINDERS!

In your program, no GLOBAL DATA are allowed, and you must write all needed functions (no library functions are allowed Except for cin and cout and their functions/manipulators)

Dynamic allocations must be released properly!

Test your output with data to be identified in class ( at least the same as being shown below as appropriate.

Attach the output at the end of your application program (as a comment).

Followed with a comment block about your logic, code issues, and any other comments that you may have YOU MUST PROVIDE this comment block even with a NO COMMENTS! as the content of this block.

SAMPLE OUTPUT

image text in transcribedimage text in transcribedimage text in transcribed

MY SOURCE CODE TO BE UPDATED

#include

using namespace std;

class Fraction {

private:

int num;

int deno;

public:

Fraction() {

num = -1;

deno = -1;

}

Fraction(int n,int d) {

num = n;

deno = d;

}

void operator =(Fraction f)

{

num = f.num;

deno = f.deno;

}

void print() {

cout

cout

cout

}

void update(int n,int d) {

if(n != -1)

num = n;

if(d != -1)

num = d;

}

bool isEmpty() {

if(num == -1 || deno == -1)

return true;

else

return false;

}

int foundInDeno(int i) {

int d = deno;

int res = 0;

while(d>0) {

int j = d%10;

if(j == i)

res++;

d = d/10;

}

return res;

}

int foundInNum(int i) {

int d = num;

int res = 0;

while(d>0) {

int j = d%10;

if(j == i)

res++;

d = d/10;

}

return res;

}

void extractUncommonDigit() {

cout

cout

int n = num;

int d = deno;

cout

while(n>0) {

int i = n%10;

if(foundInDeno(i)

cout

}

n = n/10;

}

cout

while(d>0) {

int i = d%10;

if(foundInNum(i)

cout

}

d = d/10;

}

}

};

int main()

{

int input;

Fraction f;

do {

cout

cout

cout

cout

cout

cout

cout

cout

cin>>input;

switch(input) {

case 1:

if(f.isEmpty()) {

int n,d;

cout

cin>>n;

cout

cin>>d;

Fraction fl(n,d);

f = fl;

cout

f.print();

} else {

int in;

do {

cout

cout

cout

cout

cout

cout

cout

cout

cin>>in;

int n = -1 ,d = -1;

switch(in) {

case 1 :

cout

cin>>n;

break;

case 2 :

cout

cin>>d;

break;

case 3 :

cout

cin>>n;

cout

cin>>d;

break;

case 4 :

cout

break;

default:

cout

}

if(in != 4) {

f.update(n,d);

cout

f.print();

}

} while(in!=4);

}

break;

case 2:

if(f.isEmpty()) {

cout

} else {

f.print();

}

break;

case 3:

if(f.isEmpty()) {

cout

} else {

f.extractUncommonDigit();

}

break;

case 4:

cout

break;

default:

cout

}

} while(input!=4);

}

Menu HW#3 *(1) Creating/Updating Fraction* *(2) Display the fraction *(3) Display uncommon digit(s)* (4) Quit Enter your option (1 through 4) : 2 No Fraction Available! Menu HW#3 *(1) Creating/Updating Fraction* *(2) Display the fraction *(3) Display uncommon digit(s)* *(4) Quit Enter your option (1 through 4) : 3 No Fraction Available! Menu HW#3 *(1) Creating/Updating Fraction* *(2) Display the fraction *(3) Display uncommon digit(s) (4) Quit Enter your option (1 through 4) : 1 Enter an int to numerator1237 Enter an int to denominator 110035 A cau to Fraction( int ,int ) was made to build a Fraction! num 1237 denom 110035 Menu HW#3 *(1) Creating/Updating Fraction* *(2) Display the fraction * (3) Display uncommon digit(s) *(4) Quit Enter your option (1 through 4) : 2 The current fraction object has num1237 denom 110035 Menu HW#3 *(1) Creating/Updating Fraction* *(2) Display the fraction *(3) Display uncommon digit(s)* (4) Quit Enter your option (1 through 4) : 2 No Fraction Available! Menu HW#3 *(1) Creating/Updating Fraction* *(2) Display the fraction *(3) Display uncommon digit(s)* *(4) Quit Enter your option (1 through 4) : 3 No Fraction Available! Menu HW#3 *(1) Creating/Updating Fraction* *(2) Display the fraction *(3) Display uncommon digit(s) (4) Quit Enter your option (1 through 4) : 1 Enter an int to numerator1237 Enter an int to denominator 110035 A cau to Fraction( int ,int ) was made to build a Fraction! num 1237 denom 110035 Menu HW#3 *(1) Creating/Updating Fraction* *(2) Display the fraction * (3) Display uncommon digit(s) *(4) Quit Enter your option (1 through 4) : 2 The current fraction object has num1237 denom 110035

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

differentiate between challenge and hindrance demands;

Answered: 1 week ago

Question

Help please need it by tomorrow for Bus 4 9 8

Answered: 1 week ago