C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
Question
Book Icon
Chapter 21, Problem 21.15E

a.

Program Plan Intro

Program Plan:

  • Declare variable xCoordinate and yCoordinate of type int as private member of class.
  • Provide declaration of ostream and istream operator as friend function.

Program Description: To create point class having two integer data membersxcoordinate and ycoordinate and provide declaration for stream insertion and stream extraction overloaded operator functions.

b.

Program Plan Intro

Program Plan:

  • Define overloaded insertion operator <<. Inside the definition use an if-else statement to check if the failbit was set or not.
  • If not then display the value of xCoordinate and yCoordinate data members of point class else display the message that wrong input was entered.
  • Also inside the else part use call clear function of clear the failbit.
  • Define overloaded extraction operator>>. Inside the definition use ignore function to ignore the first bracket, then read the first interger value , then again use ignore to ignore the comma and extra space, next read the ycoordinatevalue and finally use ignore to skip the last closing bracket.

Program Description: To implement the overloaded insertion and extraction functions of class point in file point.cpp.

c.

Program Plan Intro

Program Plan:

  • Include header file point.h
  • Declare a variable A of type Point.
  • Use cin statement to read the value of point in variable A.
  • Use cout statement to display the value of variable A if correct value was entered.

Program Description: To write a driver program to test the Point class.

Blurred answer
Students have asked these similar questions
Program language: C++ A publishing company markets both hardcopy and eBook versions of its work. Create a class publication that stores the title and price of a publication. From this class derive two classes: book, which adds a page count, and digital, which adds a storage capacity in MG bytes. Each of these classes should have a getdata() function to get its data from the user at the keyboard and put a putdata() function to display its data. Add a base class sales that hold an array of three floats so that it can record the dollar sales of a particular publication for the last three months. Include a getData() function to get three sales amounts from the user and a putdata() function to display the sales figures. Modify the book and digital classes so they are derived from both publication and sales. An object of the class book or digital should input and output sales data along with its other data. Write the main function to create a book object and a digital object and test their…
- Create a struct called Complex for performing arithmetic with complex numbers. Write a driver program to test your struct. Complex numbers have the form: realPart + imaginaryPart * iwhere i is the square root of -1Use double variables to represent data of the struct. Provide a function that enables an object of this struct to be initialized when it is declared. The function should contain default values in case no initializers are provided. Also provide functions for each of the following:a) Addition of two Complex numbers: The real parts are added together and the imaginary parts are added together.b) Subtraction of two Complex numbers: The real part of the right operand is subtracted from the real part of the left operand and the imaginary part of the right operand is subtracted from the imaginary part of the left operand.c) Printing Complex numbers in the form (a, b) where a is the real part and b is the imaginary partSubmit one file which contains all code above: the structure…
Write in C++ Language.   (Employee Record): Create a class named 'Staff' having the following members: Data members - Id – Name - Phone number – Address - AgeIt also has a function named 'printSalary' which prints the salary of the staff.Two classes 'Employee' and 'Officer' inherits the 'Staff' class. The 'Employee' and 'Officer' classes have data members 'Top Skill' and 'department' respectively. Now, assign name, age, phone number, address and salary to an employee and a officer by making an object of both of these classes and print the same.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr