Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ code, done in virtual studio. Please help! Create a Fraction class with private fields for whole number, numerator, and denominator. Create getter functions for

C++ code, done in virtual studio. Please help!

image text in transcribed

Create a Fraction class with private fields for whole number, numerator, and denominator. Create getter functions for each field. (public functions that allow you to retrieve the values of the private data) Create a default constructor for Fraction that prompts the user to enter 3 integers and uses them to set the private whole number, numerator, and denominator fields Overload the constructor and create a version of the constructor with this signature Fraction(int numerator, int denominator, int wholeNumber-0) Create 2 functions that are not part of the Fraction class, but make use of Fraction objects as the input arguments and/or return value void display(Fraction& f); Fraction multiply(Fraction& fractionl, Fraction& fraction2); In main, create 2 Fraction objects (letting the user enter whole number, numerator, and denominator) Use the multiply function to calculate a third Fraction that is the result of fractionl times fraction2. Display all 3 fraction objects in a reduced form. if the whole-number portion is greater than or equal to 1, show it in the output. Otherwise do not print it (ex. a fraction 1 1/2 should be displayed as is, but 0 1/3 should be displayed as 1/3) reduce the fractions (ex. 7/2 should be reduced to 3 1/2, 2 2/4 should be reduced to 2 1/2 o o Here are a few test cases you can try. Feel free to write extra helper functions (ex. reduce). Microsoft Visual Studio Debug Console Enter the whole number:0 Enter the numerator number:1 Enter the denominator number:2 Enter the whole number:e Enter the numerator number:1 Enter the denominator number:3 1/2 1/31/6 Enter the whole number:0 Enter the numerator number:2 Enter the denominator number:4 Enter the whole number:0 Enter the numerator number:3 Enter the denominator number:6 1/2 1/21/4 Enter the whole number: 1 Enter the numerator number: 1 Enter the denominator number: Enter the whole number: 2 Enter the numerator number:3 Enter the denominator number: 6 1 1/2 2 1/23 3/4

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

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions