Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 2 answer: Please answer part 3 3. In the same Java package, create a driver class with the name ComplexNumberDemoYourFirstName. Import the Q1.StudentGradesByYourFirstName class
Part 2 answer:Please answer part 3
3. In the same Java package, create a driver class with the name ComplexNumberDemoYourFirstName. Import the Q1.StudentGradesByYourFirstName class at the top so that you can use your myHeader() and myFooter() methods from that class in the same way, you did in your last lab. This class will contain two public static fields - a Scanner type instantiated field, and an int type field with an initial value 0 , and four public-static methods - dataEntry(), complexAdder(), complexMultiplier() and main(). a) Specifications for dataEntryO method: - The header: public static ComplexNumber dataEntryo - Once called, inside the method, it will increment the integer type field you declared and use it to keep the track of the number of Complex numbers as you see in the sample output that says complex number 1,2 etc. - Then it will prompt the user to enter the real and imaginary parts of a complex number and get those with the help of the Scanner type data field you already declared in this class. - At this point, it will declare a ComplextNumber type reference variable and instantiate it with the above values. - Finally, it will return the above instantiated reference variable back to the calling method. b) Specifications for comlexAdder( 0 method: o The header: public static ComplexNumber complexAdder (ComplexNumber x, ComplexNumber y) - Once called, it will declare a ComplextNumber type reference variable and instantiate it with the added real-term values of x and y, and the added imaginary-term values of x and y. Note: If there are two complex numbers x= a+bi, and y=c+di, then, x+y=(a+c)+(b+d) i. Example: if there are two complex number x=5+2i and y=43i, then, x+y=(5+4)+(213)i=911i. - It will return the above instantiated reference variable back to the calling method. c) Specifications for comlexMultiplier( ) method: - The header: public static ComplexNumber complexMultiplier (ComplexNumber x, ComplexNumber y) - Once called, it will declare a ComplextNumber type reference variable and instantiate it with the appropriate values that result from the multiplication of x and y. Note: If there are two complex numbers x=a+bi, and y=c+di, then, xy=(ac bd)+(bc+ad)i It will return the above instantiated reference variable back to the calling method. d) Specifications for the Driver Method: - Call myHeader() in the same way as you did for Q2 in your previous lab. Declare a ComplexNumber type reference variables x. Call the dataEntry() method and assign the returned value to x declared above. Repeat the same procedure for a second ComplexNumber type reference variables y. - Display the two complex numbers using the a+bi form as shown in the sample output using the displayRecForm() method. - Declare a 3rd complex reference variable called addRes. - Call the complexAdder() method with the reference variables x and y as arguments, and then assign the returned value to addRes. - Declare a 4th complex reference variable called mulRes. Call the complexMultiplier() method with the reference variables x and y as arguments, and then assign the returned value to mulRes. - Using proper method calls and appropriate print statements, display the results as shown in the sample output. Call the myFooter() method in the same way as you did for Q2 in your previous lab. See your instructor during office hours, if you have any question or concern. Fu11 Name: ....... Lab Exercise: 2, Question: 2 Program Description: A brief description.. Complex number 1 data..... Enter the real term: -12.2 Enter the imaginary term: 6.78 Comp 1 ex number 2 data..... Enter the real term: 3.4512 Enter the imaginary term: -2.7 You have entered the following two complex numbers x and y : x=12.20+6.78i y=3.452.70i Here are the results of the arithmetic operations: x+y=8.75+4.08i, Magnitude: 9.65, Angle: 155.00 degrees xy=23.80+56.34i, Magnitude: 61.16, Angle: 112.90 degrees Signing off from Question 2 - yourFirstNameStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started