C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 11, Problem 5PP

a)

Program Plan Intro

Program Plan:

  • Include header files and declare the required namespaces.
  • Create the class Fraction with two data members:num and denom.
  • Define one default constructor and one parameterized constructor in order to make fractions out of numerator and denominator.
  • Overload the operators +, -, *, / in order to perform the functioning of addition, subtraction, multiplication and division respectively.
  • Include the function gcd() for expressing the fraction into its lowest terms.

Program Description: The purpose of the program is to modifythe class Fractionin order to express the fraction into its lowest terms.

b)

Program Plan Intro

To include the class written in part (a) and verify that all the member functions work correctly.

Blurred answer
Students have asked these similar questions
(C++) 23. True/False: function getGallons() is an inline member function     24. Design a class called Date.  The class should store a date in three private integers: month, day, year.  There should be a member function to print out the date in the month/day/year format, e.g. 12/25/2015, 4/1/1970 There should be a constructor which takes three parameters to initialize the date.  It should not accept values for day greater than 31 or less than 1, or values for month greater than 12 or less than 1.  If the constructor is called with these values an error message should be printed out and the field set to 0.  Any value for year is acceptable. There do not need to be any other member functions. Provide the class declaration and also the implementation of the member function and constructor.
6. (Immutable Data Class Objects) Built-in types int, float, str and tuple are immutable. Data classes can simulate immutability by designating that objects of the class should be "frozen" after they're created. Client code cannot assign values to the attributes of a frozen object. Research "frozen" data classes, then reimplement this chapter's Complex class as a "frozen" data class. Show that you cannot modify a Complex object after you create it.
(HugeInteger Class) Create a class HugeInteger that uses a 40-element array of digits tostore integers as large as 40 digits each. Provide member functions input, output, add and subtract.For comparing HugeInteger objects, provide functions isEqualTo, isNotEqualTo, isGreaterThan,isLessThan, isGreaterThanOrEqualTo and isLessThanOrEqualTo—each of these is a “predicate”function that simply returns true if the relationship holds between the two HugeIntegers and returns false if the relationship does not hold. Also, provide a predicate function isZero. If you feelambitious, provide member functions multiply, divide and modulus.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
functions in c programming | categories of function |; Author: Education 4U;https://www.youtube.com/watch?v=puIK6kHcuqA;License: Standard YouTube License, CC-BY