Computers and Technology

This lab practices define class, more particular, identifying the member variables, declaring and defining constructors, and other member functions. Background reading:
Please review textbook for the basics of class, and the idea of Abstract Data Type Section 10.2 and 10.3 in Savitch). This project is adapted from the Project 7 in Page 614 of Savitch book.
Requirement
Write a rational number class. Recall a rational number is composed of two integers with division indicated. The division is not carried out, it is only indicated, as in 1/2, 2/3 15/32. You should represent rational numbers using two int values, numerator and denominator
A principle of abstract data type construction is that constructors must be present to create objects with any legal values. You should provide the following three constructors
1. one (default) constructor to make rational object without any argument. The constructor sets the rational object's numerator to 0, and denominator to 1
2. one constructor with two int parameters. This constructor uses the two values to initialize the rational object's numerator and denominator respectively. If the denominator value is 0, the constructor should generate an assertion failure
3. one constructor with one int parameter. The constructor should set the rational's numerator to the given parameter, and sets the denominator to 1
You should also provide the following member functions
an input function that reads from standard input the value for the calling object. The input should be in the form of "2/3" or "27/51.
an output function that displays the calling object in the terminal. The output should also be in the form of "2/3", i. e., numberator/denominator
One setter function that sets the numerator and denominator of the calling object.
Two getter functions that return the numerator and denominator respectively.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:40, jacelee17631
Write c function that can replace all the positive elements to 0 and negative to 1 in undefined length one-dimensional array. test your program in the main program by defining one-dimensional array of 6 elements
Answers: 1
image
Computers and Technology, 22.06.2019 16:10, katherineweightman
When copying and pasting text, the first step is move your cursor type the text select the copy command select the paste command
Answers: 2
image
Computers and Technology, 23.06.2019 00:00, brooklyn4932
What engine component is shown in the above figure?
Answers: 1
image
Computers and Technology, 23.06.2019 03:00, SKYBLUE1015
What are the different parts of computer
Answers: 2
Do you know the correct answer?
This lab practices define class, more particular, identifying the member variables, declaring and de...

Questions in other subjects:

Konu
Computers and Technology, 22.01.2021 20:50