Homework

Homework Questions? Ask a Tutor for Answers ASAP

Ask an Expert,
Get an Answer ASAP!

Homework
This answer was rated:

Define a class for rational numbers. A rational number is XXXXX

number that can be represented as...
Define a class for rational numbers. A rational number is XXXXX number that
can be represented as the quotient of two integers. For example, 1/2, 3/4,
64/2, and so forth are all rational numbers. (By 1/2, etc., we mean the
everyday meaning of the fraction, not the integer division this expression
would produce in a C++ program.) Represent rational numbers as two values
of type int, one for the numerator and one for the denominator. Call
the class Rational.
Include a constructor with two arguments that can be used to set the
member variables of an object to any legitimate values. Also include a
constructor that has only a single parameter of type int; call this single
parameter whole_number and define the constructor so that the object
will be initialized to the rational number whole_number/1. Also include a
default constructor that initializes an object to 0 (that is, to 0/1).
Overload the input and output operators >> and <<. Numbers are to be
input and output in the form 1/2, 15/32, 300/401, and so forth. Note that
the numerator, the denominator, or both may contain a minus sign, so
-1/2, 15/32, and -300/-401 are also possible inputs. Overload all of the
following operators so that they correctly apply to the type Rational: ==,
<, , >=, +, -, *, and /. Also write a test program to test your class.

Your class will need to store two internal, integer values for each Rational number, the numerator (top) and denominator (bottom) of the fraction. It will have three constructor functions, with zero, one and two arguments, used as follows:
Rational test1, test2(10), test3(1, 2);
The declaration for test1 calls the default (no argument) constructor, which should set the value to 0. (Like any other whole number, zero will have a 1 in the denominator: we cannot divide by zero.) The declaration for test2 calls a constructor with one argument. The value for test2 will be 10, stored as 10 on the top and 1 on the bottom. The declaration for test3 calls the constructor with two arguments. test3 is equal to 0.5, with 1 on the top and 2 on the bottom.
All of the operators required in the problem should be provided for the Rational class as overloaded, Friend functions. In general, you should be able to execute code such as following:

// Display the three values to test cout
cout << "\nTest1 equals " << test1;
cout << "\nTest2 equals " << test2;
cout << "\nTest3 equals " << test3;
// Test our operators
cout << "\nTest1 * Test2 equals " << test1*test2;
cout << "\nTest1 / Test3 equals " << test1/test3;
cout << "\nTest2 + Test3 equals " << test2+test3;
cout << "\nTest3 - Test1 equals " << test3-test1;
if (test1 == test2)
cout << "\nTest1 is equal to Test2";
if (test1 < test2) cout <> operator, to detect the use of the parentheses and the comma.
Show More
Show Less
Ask Your Own Homework Question
Answered in 4 minutes by:
10/4/2013
LogicPro
LogicPro, Engineer
Category: Homework
Satisfied Customers: 13,232
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML
Verified
Hi,
Welcome back.
What is the deadline for this?
Ask Your Own Homework Question
Customer reply replied 4 years ago

Saturday afternoon

ok, I will provide you answer ASAP.
Ask Your Own Homework Question
Customer reply replied 4 years ago

thank you


 

welcome
Ask Your Own Homework Question
Download answer from here: RationalClass_CPP.cpp

You can ask me again using "For LogicPro only" at the start of your questions like other customers to get instant answers.
It will ensure that question is for me.
Please bookmark my profile page:
http://www.justanswer.com/computer/expert-logicpro/
so you can come back and ask me a question anytime.

Remember, if you need anything else, we can continue the conversation until you’re satisfied and rate my answer as excellent. I can address follow up questions at no extra charge and I’m always here to help.
Thank you for using this site!
Ask Your Own Homework Question
Customer reply replied 4 years ago

Output is all wrong.


 


When first starting program it should look like this:


 


Please enter two non-zero integers:


 


then I type in these two integers 14 6 and hit enter.


 


The next line says:


 


Please enter Rational number:


 


Then I type in this Rational number (22, 4) and hit enter.


 


The output should be these lines:


 


Test1 equals (7, 3)


Test2 equals (14, 1)


Test3 equals (11, 2)


Test1 * Test2 equals (98, 3)


Test1 / Test3 equals (14, 33)


Test2 + Test3 equals (39, 2)


Test3 - Test1 equals (19, 6)


Test1 is less than Test2


Test2 is greater than Test3


Test3 is greater than or equal to Test1


 


Another test case?


 


Note that program has to ignor parentheses ( ) and the comma , .


 


All of the operators required in the problem should be provided for the Rational class as overloaded, Friend functions. In general, you should be able to execute code such as following:


 


// Display the three values to test cout


cout << "\nTest1 equals " << test1;


cout << "\nTest2 equals " << test2;


cout << "\nTest3 equals " << test3;


// Test our operators


cout << "\nTest1 * Test2 equals " << test1*test2;


cout << "\nTest1 / Test3 equals " << test1/test3;


cout << "\nTest2 + Test3 equals " << test2+test3;


cout << "\nTest3 - Test1 equals " << test3-test1;


if (test1 == test2)


cout << "\nTest1 is equal to Test2";


if (test1 < test2)


cout << "\nTest1 is less than Test2";


 


The above code has to be in. And a Friend function has to be used.


 

Please provide me complete requirements.

If you have any file(s), Zip all files, upload the zipped file to http://wikisend.com and post download link here.
Ask Your Own Homework Question
Customer reply replied 4 years ago

I start my code but it is all wrong. So I included the code I did along with the instructions.


 


http://wikisend.com/download/429960/Rational.zip

ok, I will review it and reply you ASAP.
Ask Your Own Homework Question
Customer reply replied 4 years ago

Thank you

welcome
Ask Your Own Homework Question
Customer reply replied 4 years ago

How see it going

Please check back in 3 hours
Ask Your Own Homework Question

Download answer from here: Rational.cpp

Please let me know if anything else is required in this.

 

Ask Your Own Homework Question
Customer reply replied 4 years ago

All most perfect. Thank You.


 


the end of the program end with:


 


Another test case?


 


and if I type y for yes it will go back to first line:


 


Please enter two non-zero integers:

ok, please wait for 10 minutes.
Ask Your Own Homework Question
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
LogicPro
LogicPro, Engineer
Category: Homework
Satisfied Customers: 13,232
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML
Verified
LogicPro and 87 other Homework Specialists are ready to help you
Ask your own question now
Hi again,
Just following up with you to see how everything is going and if you have more questions for me.
You can ask me again using "For LogicPro only" at the start of your questions like you do to get instant answers.
It will ensure that question is for me.
Please bookmark my profile page:
http://www.justanswer.com/homework/expert-logicpro/
so you can come back and ask me a question anytime.
If you need any additional information on this answer, please don't hesitate to ask by clicking on 'Reply to Expert', and I will reply as soon as possible.
I hope you found the information in my answer helpful, and if so, please let me know, here. Thank you!
Thanks very much for using Just Answer!
Best wishes
LogicPro
Ask Your Own Homework Question
Customer reply replied 4 years ago

You will start with the source code files of Displays 12.1 and 12.2, which I have attached to this lesson’s Contact as dtime.h and dtime.cpp. You'll update the class (please keep those same file names), adding the new interval_since member function, then write a test program that exercises the updated class. I want the test program to exercise all of:
Both constructors
The overloaded >> operator
The overloaded << operator
The overloaded == operator
The advance member function
The new interval_since member function

Could you elaborate?
Ask Your Own Homework Question
Customer reply replied 4 years ago

The files below must have new interval_since function and it must exercise all of


 


Both constructors
The overloaded >> operator
The overloaded << operator
The overloaded == operator
The advance member function
The new interval_since member function


 


 


http://wikisend.com/download/601650/files.zip

As it is new requirement, please open a new thread using "For Logicpro only"

Once I reply on that page, you can copy paste the question

Go to following link

http://www.justanswer.com/homework/expert-logicpro/

to create the question under my profile

Ask Your Own Homework Question
Customer reply replied 4 years ago

I paid for an assignment last week so I have a credit. that why I asking now.

That question is open to other experts. You can create a new question for this requirement
Ask Your Own Homework Question
Customer reply replied 4 years ago

So how do I use my credit?


 

It was about "5 years Pro-Forma Income Statement"
You can send the details to info @ justanswer.com (without space) and ask them please.

Thanks
Ask Your Own Homework Question
Ask LogicPro Your Own Question
LogicPro
LogicPro
LogicPro, Engineer
Category: Homework
Satisfied Customers: 13,232
13,232 Satisfied Customers
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML

LogicPro is online now

A new question is answered every 9 seconds

How JustAnswer works:

  • Ask an ExpertExperts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional AnswerVia email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction GuaranteeRate the answer you receive.

JustAnswer in the News:

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help.

Mary C.Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!

AlexLos Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.

GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

JustinKernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around.

EstherWoodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know.

RobinElkton, Maryland

He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here.

DianeDallas, TX

< Previous | Next >

Meet the Experts:

LogicPro

LogicPro

Engineer

13,232 satisfied customers

Expert in Java C++ C C# VB Javascript Design SQL HTML

Manal Elkhoshkhany

Manal Elkhoshkhany

Tutor

4,549 satisfied customers

More than 5000 online tutoring sessions.

Linda_us

Linda_us

Finance, Accounts & Homework Tutor

3,138 satisfied customers

Post Graduate Diploma in Management (MBA)

Chris M.

Chris M.

M.S.W. Social Work

2,635 satisfied customers

Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)

F. Naz

F. Naz

Chartered Accountant

2,158 satisfied customers

Experience with chartered accountancy

Bizhelp

Bizhelp

CPA

1,887 satisfied customers

Bachelors Degree and CPA with Accounting work experience

Seanna

Seanna

Tutor

1,781 satisfied customers

3,000+ satisfied customers, all topics, A+ work

< Previous | Next >

Related Homework Questions
I need help implementing expectation maximization algorithm
I need help implementing expectation maximization algorithm in python … read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
181 satisfied customers
Section 1 – Objectives: Provide a brief summary of the
Section 1 – Objectives: Provide a brief summary of the project. • Section 2 – Task 1: Basic Web Tracking Mechanism: Summarize your efforts to investigate web tracking, including the screenshots you to… read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
181 satisfied customers
I have 3 more if you want them, i have to pick a heroine,
i have 3 more if you want them, i have to pick a heroine, and do these assignments, let me know, and let me know what its worth, when this one is done, i will send you the other two, and pay seperatel… read more
O. Adames
O. Adames
Bachelor\u0027s Degree
77 satisfied customers
I need help with advanced macroeconomics. I'm having trouble
I'm having trouble with the IS-MP-PC model, showing what would happen if the FFR would be increased, and also if there were to be a tax reform. … read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
181 satisfied customers
Is there any help for Linux beginners testout chapter exams.
is there any help for Linux beginners testout chapter exams … read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
181 satisfied customers
With a minimum word count of 130: Do you believe business
With a minimum word count of 130: Do you believe business enterprise should be regulated by the federal government or that the marketplace should determine price? Explain your response.… read more
Experienced Teacher
Experienced Teacher
Bachelor\u0027s Degree
394 satisfied customers
Prepare 10 column work sheet for fiscal year 2005 starting
prepare 10 column work sheet for fiscal year 2005 starting with unadjust trial balance including adjustments on additional facts?… read more
Manal Elkhoshkhany
Manal Elkhoshkhany
Tutor
Foundation classes for MBA
4,549 satisfied customers
Need an SQL query written that will create a row for every
Need an SQL query written that will create a row for every possible date. I need it to take all invoices, payments and exchange rates and create a row for each record so that it can be filtered by exa… read more
The-PC-Guy
The-PC-Guy
Bachelor\u0027s Degree
628 satisfied customers
We have a project that is due October 29, I have scanned the
Angela, We have a project that is due October 29, I have scanned the info for it but I don't know how to get them to you. Could you please let me know how I can get them to you? Here is the file : dow… read more
Seanna
Seanna
Tutor
1,781 satisfied customers
For LogicPro only: I need to develop a code using SQL for a
For LogicPro only: I need to develop a code using SQL for a cookbook database. Below are the requirements:Provide the SQL CREATE TABLE commands for the five tables in your cookbook database. Include P… read more
LogicPro
LogicPro
Engineer
13,232 satisfied customers
I need some one to answere a couple excel question. Excel
I need some one to answere a couple excel question … read more
Jason Jones
Jason Jones
AAS Information Technology
6,316 satisfied customers
Program 1) A small company is moving all its employee data
Program 1) A small company is moving all its employee data to a computer. To make a smooth transition, a software program will permit the data entry personnel to enter data into a file. Design a progr… read more
LogicPro
LogicPro
Engineer
13,232 satisfied customers
Paying a large tip to secure a better table in a restaurant
Paying a large tip to secure a better table in a restaurant is the same as offering a bribe in business to secure a contract." Defend or oppose this statement.… read more
KARRY
KARRY
Master's Degree
92 satisfied customers
For a list of numbers entered by the user and terminated by
For a list of numbers entered by the user and terminated by 0. Write a program to find the sum of the positive numbers and the sum of the negative numbers. Needs to be done in Raptor Program.… read more
LogicPro
LogicPro
Engineer
13,232 satisfied customers
Need a biography on Woodrow to include the following info:
Angela, Need a biography on Woodrow Wilson to include the following info: 1. Term of presidency and date of service, date of birth, date of death, birthplace, and family history 2. Political affiliati… read more
Seanna
Seanna
Tutor
1,781 satisfied customers
While arguing with his neighbor, pulls out a Swiss Army
While arguing with his neighbor, Sam pulls out a Swiss Army knife with the intent of merely frightening him. Sam accidentally hits his neighbor's arm with the knife, resulting in a slight nick. Unbekn… read more
RobertJDFL
RobertJDFL
Attorney
Juris Doctorate
5 satisfied customers
Paul's missionary work created a controversy in the church.
Paul's missionary work created a controversy in the church. what was the nature of the Jew-Gentile controversy and how did the church handle it?… read more
Academic Tutor
Academic Tutor
Master\u0027s Degree
380 satisfied customers
Will your tutors assist with an entire exam? I have the
hello, will your tutors assist with an entire exam? … read more
David L.
David L.
Bachelor\u0027s Degree
6 satisfied customers
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Show MoreShow Less

Ask Your Question

x