A) Write a program to print the sum of two complex numbers by creating a class named as "ComplexNumbers' containing two data members, real and imaginary and two functions. First function named as 'plus' adds the given two complex numbers and updates the first complex number with the result and the second function named as 'print' prints the given sum in the format 'a + ib' where a is the real part and b is the imaginary part. Take the real and imaginary parts of both the complex numbers as input from scanner and consider them to be positive integers. Input Format : Line 1: Two integers- real and imaginary part of 1st complex number Line 2: Two integers- real and imaginary part of 2nd complex number Sample Input : 45 (write program in java) 67 Sample Output : 10 + il2
A) Write a program to print the sum of two complex numbers by creating a class named as "ComplexNumbers' containing two data members, real and imaginary and two functions. First function named as 'plus' adds the given two complex numbers and updates the first complex number with the result and the second function named as 'print' prints the given sum in the format 'a + ib' where a is the real part and b is the imaginary part. Take the real and imaginary parts of both the complex numbers as input from scanner and consider them to be positive integers. Input Format : Line 1: Two integers- real and imaginary part of 1st complex number Line 2: Two integers- real and imaginary part of 2nd complex number Sample Input : 45 (write program in java) 67 Sample Output : 10 + il2
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.3: Class Scope And Duration Categories
Problem 4E
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images
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.Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning