Complex Numbers Calculator
The primary objective of this assignment is to gain practical experience in C++. In this assignment you will create a program that simulates a complex numbers calculator using C++. The proposed program should display the following screen to the user (Figure 1):
Please choose one of the following options:
(1) Add
(2) Subtract
(3) Multiply
(4) Divide
(5) Find Conjugate
(6) Quit
What is your choice (Please enter a number)?
(Figure 1 – Main Screen)
As soon as we have the user choice, one of the following windows should appear to the user:
Adding two complex numbers:
This will appear if the user choice was 1. It should enable the user to add two complex numbers to find their sum.
The user must enter two complex numbers. The program will find their sum, display the result to the user and it should enable the user to get back to the main screen.
Adding two complex numbers:
Enter the first number without spaces (for example: 2+i3):
5+i6
Enter the second number without spaces (for example: 2+i3):
7-19
result is: 12-i3
press enter to continue..
(Figure 2 – Show Adding two complex numbers screen)
Subtract two complex numbers:
This option is initiated when the user chooses (2) in the main screen. The user has to enter two complex numbers. The program will find their subtraction, display the result to the user and it should enable the user to get back to the main screen.
Subtract two complex numbers:
Enter the first number without spaces (for example: 2+i3):
6+i5
Enter the second number without spaces (for example: 2+i3 ):
4+i2
result is: 2+i3
press enter to continue..
(Figure 3 - Show Subtracting two complex numbers screen)
Multiply two complex numbers:
This option is initiated when the user chooses (3) in the main screen. The user has to enter two complex numbers. The program will find the multiplication of the two given complex numbers, display the result to the user and it should enable the user to get back to the main screen.
Multiply two complex numbers:
Enter the first number without spaces (for example: 2+i3):
2+i3
Enter the second number without spaces (for example: 2+i3):
1-14
result is: 14-i5
press enter to continue..
(Figure 4 - Multiply two complex numbers screen)
Divide two complex numbers:
This option is initiated when the user chooses (4) in the main screen. The user has to enter two complex numbers. The program will divide the two given complex numbers, display the result to the user and it should enable the user to get back to the main screen.
Divide two complex numbers:
Enter the first number without spaces (for example: 2+i3 ):
5+i7
Enter the second number without spaces (for example: 2+i3 ):
2+i4
result is: 1.9-i0.3
press enter to continue..
(Figure 5 - Divide two complex numbers screen)
Find Conjugate of a complex number:
This option is initiated when the user chooses (5) in the main screen. The user has to enter one complex number. The program will find the conjugate of the given complex number, display the result to the user and it should enable the user to get back to the main screen.
Find Conjugate of a complex number:
Enter the number without spaces (for example: 2+i3):
2.5-i5
result is: 2.5+i5
press enter to continue..
(Figure 6 - Find Conjugate of a complex number screen)
Quit the program:
This option is initiated when the user chooses (6) in the main screen. The program will print “press enter to continue..” then the program will terminate as soon as the user hits any key.
Please choose one of the following options:
(1) Add
(2) Subtract
(3) Multiply
(4) Divide
(5) Find Conjugate
(6) Quit
What is your choice (Please enter a number)?6
press enter to continue..
(Figure 7 - Quit the program)
Important Notes:
- Make sure to represent each complex number as an object that has (real and imaginary parts).
- You can use the template provided in the attachment or you can create your own code from scratch if you like (Please pay attention that the code in the attached template will not compile as is, because it is not complete yet).
- It is so important to submit a working program (Non-working applications will NOT be considered).
- Make sure to consider Object Oriented Programming when designing the code (consider using classes and objects: Complex class, Handler class, ..) and to include the code of all required classes and
methods.
- Make sure to implement code for operators +, -, *, / in Complex class.
- You must submit one file only (a zip file that includes all your code).
- You can run (attached demo.out file using: ./demo.out) to get a better idea on how the program should work.
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。