Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop using C++. Programam: main3.cpp, fraction.hpp, fraction.cpp maketile Rubrics that apply: All Points Possible: 100 Description Define a class called fraction that will hold a

image text in transcribed

Develop using C++.

Programam: main3.cpp, fraction.hpp, fraction.cpp maketile Rubrics that apply: All Points Possible: 100 Description Define a class called fraction that will hold a numerator, denominator, and the decimal representation of the fraction. The class should define a default constructor that will set the numerator and the denominator to 1 and the correct decimal representation. There should be another constructor that will accept the numerator and denominator as parameters. To set the values for the constructors, use an initialization section. Write overloaded fraction operators to add, subtract, multiple, and divide fractions. Write an overloaded cout operator that will print out the fraction as x/y. Write an overloaded cin function that will ask for a numerator and denominator of a fraction. You will also write a function that will calculate the decimal equivalent of the fraction. You should also have a function that will reduce the fraction and return the result. The original fraction should still be saved. For example, if the fraction is 6/10, this function should return 3/5, but if the original fraction should still be stored as 6/10 In the main function, you are going to write code that will display the following menu 1. Add fractions 2. Subtract fractions 3. Multiple fractions 4. Divide fractions 5. Reduce a fraction 6. Show the decimal equivalent of a fraction 7. Exit the program For the first 4 cases, the program should ask for the 2 fractions. For 4 -6, the program should ask for 1 fraction. Sample output Enter1 numerator denominator (space in between) 1 3 Enter 2 numerator denominator: 3 6 Result: 5/6 nd Enter numerator denominator (space in between) 46 Result: 2/3 Class member variables: e numerator denominator . decimal equivalent Class member functions Default constructor Constructor that will accept numerator and denominator Overloaded +, -,/, * Overloaded > Function that will calculate the decimal equivalent Func tion that will give the reduced fraction Requirements Fraction must be implemented in a class with the above requirements. No global variables are to be used

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 Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

More Books

Students also viewed these Databases questions