Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add the following operations to the Fraction class (HINT: After you complete the __cmp__ function, the remaining functions can use the __cmp__, making them almost

Add the following operations to the Fraction class (HINT: After you complete the __cmp__ function, the remaining functions can use the __cmp__, making them almost trivial.):

__cmp__ - This function should take another fraction as the parameter and return: a negative value if the current fraction is less than the parameter fraction zero if the current fraction and the parameter fraction have the same value a positive value if the current fraction is greater than the parameter fraction

__eq__ - This function should take another fraction as a parameter and return True if the current fraction is equal to the the parameter fraction; otherwise False

__ne__ - This function should take another fraction as a parameter and return True if the current fraction is not equal to the the parameter fraction; otherwise False

__lt__ - This function should take another fraction as a parameter and return True if the current fraction is less than the parameter fraction; otherwise False

__le__ - This function should take another fraction as a parameter and return True if the current fraction is less than or equal to the parameter fraction; otherwise False __gt__ - This function should take another fraction as a parameter and return True if the current fraction is greater than the parameter fraction; otherwise False

__ge__ - This function should take another fraction as a parameter and return True if the current fraction is greater than or equal to the parameter fraction; otherwise False Modify the main program to test these new operations, including ==, !=, <, >, <=, >=.

Create a Abstract Data Type called Percentage which is derived from a Fraction

Add a __str__() operation that converts the fraction to display as a percentage.

For example, the fraction 4/5 should display as 80.0%.

Create a main program that creates a couple of percentages that add up to 100%.

Compute a weighted average of several made up test scores.

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 Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

3. An overview of the key behaviors is presented.

Answered: 1 week ago

Question

2. The model is credible to the trainees.

Answered: 1 week ago