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

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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