Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language is c++ and need to run it in code blocks. Fractions In this lab you'll be creating your own class called Fraction that stores

Language is c++ and need to run it in code blocks.

image text in transcribed

Fractions In this lab you'll be creating your own class called Fraction that stores a fractional value Your Fraction class will have the following integer member variables (attributes) num representing the numerator den representing the denominator (must be non-zero) Your Fraction class should have the following member functions (methods) Constructors: one general and one default constructor- don't forget to do input validation on denominator Accessors: Mutators: on denominator one get function for each member variable one set function for each member variable - don't forget to do input validation * void print): ction to display the fraction in standard format, e.g. 1/2 . double getDecimal() calculates the decimal equivalent of the fraction and returns it. Your main function should: 1. Create a Fraction object and use the general constructor to initialize it to 6/10. 2. Call print on the object. 3. Create an array of 3 Fraction objects. 4. Prompt the user for the values of the numerator and denominator of the 3 Fractions and use the mutators to set their values. Find the item with: 5. o o o The largest numerator The largest denominaton The largest decimal equivalent. If you want, you can use the following values for your 3 fractions to test whether your code from part 5 works correctly: 1/100, 5/40, 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

Students also viewed these Databases questions