Design and implement an immutable fraction class

Assignment Help Basic Computer Science
Reference no: EM132253907

Please solve this question in C++

Program Description:

Design and implement an immutable Fraction Class described in the Fraction case study. Your class must have the following methods to emulate arithmetic, relational, and I/O operations on Fractions.

1. Arithmetic operators: + - * /

2. Relational operators: < <= > >=

3. Equality operators: == !=

4. Stream Extraction: >> (i.e. 3/7 form)

5. Stream Insertion: << (i.e. 3/7 form)

6. Method to reduce fraction

Specific Requirements:

  • Your main testing program may only have two variables: start and userFraction which are both of type Fraction.
  • start should contain values set by you that are passed into the constructor.
  • userFraction should start out calling the default constructor and then have its values set through the overloaded >> operator.
  • There are to be no get/set methods for the Fraction class. Having get/set methods in your class will cause you to lose significant points.
  • Note that the testing program displays the words true or false for the relational operator testing.

Be sure to test your program with several different fractions, but for your output you report to me, use the exact test values from the example output. Demonstrate all methods implemented.

Helpful notes:

  • You should create a .h file and two different .cpp files for this lab.
  • You will not need to create a destructor.
  • You may consider making a private helper function or two for simplifying your fraction.

Example output:

*****Fraction Demonstration*****

We will start with the fraction 3/5

Enter a new fraction:

Numerator: 6

Denominator: 8

Your simplified fraction is: 3/4

********************************

Demonstrating overloaded math operators: -, +, *, /

This will show negation of 3/5 and then our two fractions

3/5 and 3/4 added, multiplied, and divided.

-: -3/5

+: 27/20

*: 9/20

/: 4/5

********************************

Demonstrating overloaded relational operators: <, <=, >, >=, == !=

by comparing 3/5 with 3/4.

<: true

<=: true

>: false

>=: false

==: false

!=: true

********************************

Reference no: EM132253907

Questions Cloud

Idea of creating local shrimp supply chains : Would it be feasible to expand the idea of creating local shrimp supply chains?
Describe four wireless technologies-standards : Describe what each one does and briefly how it works? How is each one different from the other standards?
What social and psychological variables do you believe : What various social and psychological variables do you believe potentially influenced the outcome of this case - analyze your own thoughts and feelings
Identify one of the firms major competitors : Create a SWOT analysis for the company to determine its major strengths, weaknesses, opportunities, and threats.
Design and implement an immutable fraction class : Design and implement an immutable Fraction Class described in the Fraction case study. Your class must have the following methods
What information would you need to test the claim : Employees from Company A and Company B both receive annual bonuses. What information would you need to test the claim that the difference in annual bonuses.
Explain the various logistics systems of organization : Explain the various logistics systems of an organization and role of MIS at every level to be highlighted.
Obtain information regarding the annual reports : ACCT440 Each student will pick two publicly traded companies for two fiscal years. Students will use (Securities and Exchange Commission) website to obtain.
Military policy states that behavioral science consultant : A military policy states that "behavioral science consultant" may not be "medical monitor during interrogation" and suggests that this is "health care function.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd