s 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 :
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Write a
‘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 2
nd complex number
Sample Input :
4 5
6 7
Sample Output :
10 + i12
Please solve this program in java, and help me.
PROGRAM IN JAVA
Step by step
Solved in 2 steps