Create class named fraction which represent new data type

Assignment Help Programming Languages
Reference no: EM131071832

1. Create a class named fraction which will represent a new data type corresponding to fractions. Your class should create the following private members:

- Integers n and d corresponding to the numerator and denominator of the fraction

- A function gcd which returns the greatest common divisor of 2 integers (to help you reduce the fraction).

And the following public member functions:

- 3 constructors which will create any fraction when declared with 2 integers, will create a/1 when declared with 1 integer, and will create 0/1 when declared with no integers.

- num which returns the numerator of the fraction

- denom which returns the denominator of the fraction

- reduce which reduces the fraction to its lowest terms (using the gcd function above). This function changes the value of n and d appropriately.

- convert which returns a double representing the fraction (i.e. ¾ becomes 0.75)

You are to overload the following operators: +, -, ∗, /, + =, - =, ∗ =, / =, <, <=, >, >=, ==, ! = for use with fractions. For the operators +, -, ∗, /, + =, - =, ∗ =, / =, calculate the new fraction in lowest terms (like 3/4 instead of 6/8). Overload + and - for both unary and binary operations.

Also overload << and >> to accept and display fractions in the form a/b. A fraction like a/1 should be displayed as a. You can assume that a fraction will always be input in the form a/b.

Reference no: EM131071832

Questions Cloud

Identify two potential trading partners with justification : Analyze in a minimum of 1,050 words, using this case study as the basis, the impact of currency manipulation on cross-border trade and investment activities.
Write your maximum error-free channel capacity function : For your function what is the instantaneous rate of change in maximum error-free channel capacity with respect to SNR, for SNR=30? What is the equation of the tangent line to the graph of C(SNR), when SNR=30?
Eliminate exchange rate risk : (a) Detail the hedging strategy with options. (b) Estimate the cost today of an options strategy that will eliminate exchange rate risk.
Create a sourcing plan for future requirements : Develop a document that creates a sourcing plan for future requirements. In the sourcing plan, you should explain inclusions that should be made in contracts formed in the future
Create class named fraction which represent new data type : Math 3300 Programming Assignment. Create a class named fraction which will represent a new data type corresponding to fractions. Your class should create the following private members: Integers n and d corresponding to the numerator and denominator..
Identify and research one not-for-profit organization : Identify and research one not-for-profit organization and provide the Web link to the most recent financial report of the organization.
Regular savings program : Concerned that his spending had gotten out of control and that he was barely making it from paycheck to paycheck, he decided to list his expenses for the past calendar year and develop a budget. He hoped not only to reduce his credit card debt but..
Write a c++ program that simulates a simple bank statement : Write a C++ program that simulates a simple bank statement. The program should ask the user to enter their first name, last name, account number, gender(M/F) and initial balance in the account
Which of them is true of countries with low masculinity : Which of the following subsystems is most likely to underlie both moral and economic norms?

Reviews

Write a Review

Programming Languages Questions & Answers

  What are the disadvantages of using technology

Describe your reasons for choosing this virtualisation technology, what advantages does this virtualisation and technology give you in this scenario - What are the disadvantages of using this technology?

  Write a class named car that has the member variables

Write a class named Car that has the following member variables: YearModel. An int that holds the car's year model

  Write a perl program that performs show current date

Write a Perl program that performs the following tasks: Generate a menu to ask the user for the task that he or she would like to see performed. The available tasks are as follows: Show current date and time

  Use shared mutex for synchronization and locking mechanism

Execute two programs of matrix multiplication with thread programming. Use the shared mutex for synchronization and locking mechanism.

  What are the consequences of not citing computer programs

Review the document on code citation and documentation guidelines in the Course Materials section of your student Web site and the Avoiding Plagiarism tutorial available on your student Web site. Discuss the issues of proper citation as they apply..

  Perform object-oriented analysis and design

OOAD's increasing popularity is brought about in part because of its ability to represent complex relationships, as well as data and data processing, with a consistent notation.

  Develop procedure to returns recent order information

Develop a procedure that returns the most recent order information for aparticular basket. This procedure must determine most recent stage entry from the BB_BASKETSTATUS table

  Write program in mips to compute average of series of number

Write program in MIPS which computes average of a series of entered numbers. User will enter a sequence of integers. When the user enters a negative number.

  Write a prolog program to solve the water jugs problem

Write a Prolog program to solve the water jugs problem: There are two jugs, one holding 3 and the other 5 litres of water. A number of things can be done with the jugs: they can be filled, emptied, and dumped one into the other either until the pou..

  Create a console-mode executable class

Create a console-mode executable class (no GUI in this project; let's keep it simple) using the following specifications.

  Implementing efficient code on the gpu with cuda

Com4521/Com6521: Parallel Computing with GPUs. The aim of the assignment is to test your understanding and technical ability of implementing efficient code on the GPU with CUDA. You will be expected to benchmark and optimise the implementation of a..

  Projects for the falling letters game

Design and implement two projects for the Falling Letters game using C# and Windows Presentation Foundation (WPF) template in Visual Studio 2012 or newer.

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