Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROJECT 1 Fractional Number Class - Frac Total of 30 points The following information, located on Github m03, are provided as a starter. Frac.h, a

PROJECT 1 Fractional Number Class - Frac

Total of 30 points

The following information, located on Github m03, are provided as a starter.

  1. Frac.h, a complete Frac Class Declaration ( the definition is to be complete by you.) LINK TO THE GITHUB: https://github.com/dvcchern/CS200/blob/master/m03/Frac.h
  2. testFrac_starter.cpp, a working program with partial Frac members defined to get you started. LINK TO THE GITHUB: https://github.com/dvcchern/CS200/blob/master/m03/testFrac_starter.cpp

Please follow the TODO List below to finish all Class definitions, and to expand the starter to exercise and verify all the Frac member methods.

What is the number Type?

In our daily life we use the Quantitative Numbers to represent the physical world, such as:

  • Time or Angle in HMS (Hour-Minute-Second),
  • Length in Feet-Inches,
  • Floating Point Number in Mantissa and Exponent

For example, a floating number

123.45 = 1.2345 10+2(for 10-based)

  • Mantissa: 1.2345(normalized significant part of the value)
  • Exponent: -2

The floating point number construction and operations are pretty complicated but using the floating point number type in C++ is pretty straight forward. Since all the commonly used floating number operators are defined (overloaded) to have the same look and feel like an integer data type.

What is a Fractional number?

The fractional numbers are figured out by two whole numbers (the fraction terms) that are separated by a horizontal line (the fraction line). The number above the line (the numerator) can be every whole number and the number below the line (the denominator) should be different from zero.

Here are some examples of some fractions: 3/4, 5/4,...

Project Requirement

The form and format the Fractional number to be used

In this project, We are only going to

(1) use two numbers: numerator over denominator to represent a fraction, no mixed numerals.

(2) allow the usage of the proper and improper fraction:

  • Proper Fraction: the number is inferior to the denominator, for instance3/4;
  • Improper fraction: the numerator is superior to the denominator, for instance9/2;

We are not going to use Mixed Fraction and Equivalent Fractions:

  • Mixed Fraction or Mixed Numeral: it is composed of a whole part and a fractional one, for instance21/3;
  • Equivalent Fractions: fractions that keep on the same proportion of another fraction, for instance:5/2=10/4;All Fraction shall be the minimum number representation.

TODO List

Part-1

To complete the definition of all Five (5) Required Frac class method groups:

All items listed below must be verified in your submission!

1.Constructors: *you may combine the first 3 Contructors below into one.

  • Default: numerator default as 0, denominator default as 1
  • One (1) argument Fill Constructor: (int numerator) numerator only, denominator default as 1
  • Two (2) arguments Fill Constructor: (int numerator, int denominator)
  • String Constructor: (string s); where s in the format of "3/4"

2. Necessarygettersandsetters

3. Support the following operators:

  • basic math:+, -, *. /
  • pre and postfix++and-- (4 different types)
  • comparators:, =, !=, ==

4. Type conversion operators, to convert Frac numbers to integer or floating point numbers:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
\f// line #74 onward cout , =, !=, == x > y is: true x = y is: true x > Enter a fraction to test iostream operators: 5/6 You have entered: 5/6 Part-2 Operators in one statement v. separated statements. 11/6 11/6 11/6 11/6 11/6 11/6 11/6 5/6 5/6 11/6 5/6 11/6 Provide your observation and explanation as part of the submission. Exit code: 0 (normal program termination) cout

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Public relations and marketing

Answered: 1 week ago