Make a program in Java language that performs Addition, Subtraction and Multiplication of two complex numbers -There should be a menu -The operations must be functions and/or procedures that must be called in the main program
Make a program in Java language that performs Addition, Subtraction and Multiplication of two complex numbers -There should be a menu -The operations must be functions and/or procedures that must be called in the main program
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Make a
-There should be a menu
-The operations must be functions and/or procedures that must be called in the main program
Expert Solution

Program Approach
The steps to create the program are mentioned below.
- Create a class menu to define the complex numbers and the operations to be performed on them.
- Create two float variables to hold the real and imaginary values.
- Create a parameterized constructor to initialize the object of the class with the parameters passed to it.
- Define method disp to display the complex number equation.
- Define the add method to add the two complex numbers by adding the real and imaginary parts separately.
- Define the sub method to add the two complex numbers by subtracting the real and imaginary parts separately.
- Define the mul method to add the two complex numbers by multiplying the real and imaginary parts separately.
- Create public myClass to implement complex number operations using the main method.
- Create two complex numbers using the object of the menu class.
- Display the menu with the addition, subtraction, and multiplication operations.
- Use a do-while loop to continue with the operations if the user wishes to.
- Input the choice of operation from the user and use it in the switch statement.
- Call the respective methods and display the result for each case of choice.
- Ask the user if they wish to continue and take input in the variable cont.
Step by step
Solved in 4 steps with 6 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

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

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