C++ How To Program Plus Mylab Programming With Pearson Etext -- Access Card Package (10th Edition)
10th Edition
ISBN: 9780134583006
Author: Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 13, Problem 13.16E
(Complex Class) Write a
- Create a user-defined class Complex that contains the private integer data member'' real and imaginary and declares stream insertion and stream extraction overloaded operator functions as friends of the class.
- Define the stream insertion and stream extraction operator functions. The stream extraction operator function should determine whether the data entered is valid, and, if not, it should set fail bit to indicate improper input. The input should be of the form 3 + 81
- The values can be negative or positive, and it’s possible that one of the two values is not provided, in which case the appropriate data member should be set to 0. The stream insertion operator should not be able to display the point if an input error occurred. For negative imaginary values, a minus sign should be printed rather than a plus sign.
- Write a main function chat tests input and output of user-defined class Complex, using the overloaded stream extraction and stream insertion operators.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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.
C++ Programming.
Topic:
Working with pointers and dynamic memory. Indicators. Working with dynamic memory. Dynamic arrays and their use as function parameters.
Task :
Describe a void function named Swap(x,y) that swaps the values stored in the variables x and (x is a real type parameter and is both input and output). Using this function , for the given variables of real type a, b, c, d, one should sequentially replace the values of the pairs (a, b), (c, d) and (b, c) and let a, b, c, d be new values .
State whether the following are true or false. If the answer is false, explain why.a) A pointer that’s declared to be void can be dereferenced.
Chapter 13 Solutions
C++ How To Program Plus Mylab Programming With Pearson Etext -- Access Card Package (10th Edition)
Ch. 13 - (Write C ++ statements) Write a statement for each...Ch. 13 - (Inputting Decimal, Octal and Hexadecimal Values)...Ch. 13 - Prob. 13.8ECh. 13 - (Printing with field Widths) Write a program to...Ch. 13 - (Rounding) Write a program that prints the value...Ch. 13 - (Length of a String) Write a program that inputs a...Ch. 13 - (Converting Fahrenheit to Celsius) Write a program...Ch. 13 - In some programming language, string are entered...Ch. 13 - Prob. 13.14ECh. 13 - Prob. 13.15E
Knowledge Booster
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
- - 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…arrow_forward3A in Python language please:arrow_forward(Complex Class) Write a program that accomplishes each of the following:a) Create a user-defined class Complex that contains the private integer data members realand imaginary and declares stream insertion and stream extraction overloaded operatorfunctions as friends of the class.b) Define the stream insertion and stream extraction operator functions. The stream extraction operator function should determine whether the data entered is valid, and, ifnot, it should set failbit to indicate improper input. The input should be of the form3 + 8ic) The values can be negative or positive, and it’s possible that one of the two values is notprovided, in which case the appropriate data member should be set to 0. The streaminsertion operator should not be able to display the point if an input error occurred. Fornegative imaginary values, a minus sign should be printed rather than a plus sign.d) Write a main function that tests input and output of user-defined class Complex, usingthe overloaded…arrow_forward
- .“Dangling and wild pointers are known to be problems with pointers”. Justify the given statement with the helpof suitable examplearrow_forwardUSE PYTHON PROGRAMMING LANGUAGE(OOP) 1. (Geometry: n-sided regular polygon) An n-sided regular polygon’s sides all have the same length and all of its angles have the same degree (i.e., the polygon is both equilateral and equiangular). Design a class named RegularPolygon that contains: ■ A private int data field named n that defines the number of sides in the polygon. ■ A private float data field named the side that stores the length of the side. ■ A private float data field named x that defines the x-coordinate of the center of the polygon with a default value 0. ■ A private float data field named y that defines the y-coordinate of the center of the polygon with a default value 0. ■ A constructor that creates a regular polygon with the specified n (default 3), side (default 1), x (default 0), and y (default 0). ■ The accessor and mutator methods for all data fields. ■ The method getPerimeter() returns the perimeter of the polygon. ■ The method getArea() returns the area of the…arrow_forward(Modifying Class GradeBook) Modify class GradeBook (Figs. 16.11–16.12) as follows:a) Include a second string data member that represents the course instructor’s name.b) Provide a set function to change the instructor’s name and a get function to retrieve it.c) Modify the constructor to specify course name and instructor name parameters.d) Modify function displayMessage to output the welcome message and course name,then the string "This course is presented by: " followed by the instructor’s name.Use your modified class in a test program that demonstrates the class’s new capabilities.arrow_forward
- X Whether the following statement is TRUE or FALSE? When an object is returned by a function, a temporary object is automatically created to hold the return value.arrow_forward(FRP7) Write a function that reads data from a file. The file has already been opened and verified. The data should be saved in the array of type ship. The size of the array is passed in the int parameter and the number of records read is return in the last parameter, by reference. The file should be read until end of file has been reached or the array is full. struct ship{ string shipCaptain; string shipName; }; The function prototype isvoid readFile( ifstream&, ship[ ], int, int& ); ifstream - The already open file ship[ ] - array of structs where the data from the file will be stored. int - the size of the array. int& - the number of records read from the file. This value is set by the function before returning return- the number of records read from the file, returned by the function. The amount of data in the file is unknown but there is no bad data. The file format is the shipsName followed by the shipsCaptiain . Example: MillenniumFalcon HansSoloarrow_forwardTopical Information Use C++. This lab will help you practice with dynamic memory (NOT mixed with classes). Program Information One statistic of interest to many researchers is the median of a set of data. The median is the value in the middle. (This is NOT the average, mind you.) Being in the middle, of course implies that the data are in order (sorted). If there are an odd number of data items, the middle is simple to find. If there are an even number of data items, you are supposed to take the average of the two middle values. You'll need to find the median of a set of data from a file. You don't know how many data are in the file, of course. You'll have to count the data, then read them in to sort, then find the median, and finally print it (the median) out. Do NOT use any more memory than is necessary!!arrow_forward
- //arrow_forwardIndicate whether the following is true or false:Only pointers and references are permissible for use with dynamically bound virtual functions.arrow_forward(Reading Phone Numbers with and Overloaded Stream Extraction Operator) In Fig. 18.5,the stream extraction and stream insertion operators were overloaded for input and output of objectsof the PhoneNumber class. Rewrite the stream extraction operator to perform the following errorchecking on input. The operator>> function will need to be reimplemented.a) Input the entire phone number into an array. Test that the proper number of charactershas been entered. There should be a total of 14 characters read for a phone number ofthe form (800) 555-1212. Use ios_base-member-function clear to set failbit for improper input.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
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