In this exercise, using C++ and Qt 5/6, you will design a simple calculator with four basic operations, namely addition,

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

In this exercise, using C++ and Qt 5/6, you will design a simple calculator with four basic operations, namely addition,

Post by answerhappygod »

In this exercise, using C++ and Qt 5/6, you will design asimple calculator with four basic operations, namelyaddition,subtraction, multiplication, and division. Implementation of thissimple calculator should separatethe code for user interface and mathematical operations.The code for performing mathematical operations should be designedusing the following classhierarchy:The Operation class hierarchy contains the logic for performingvarious mathematicaloperations. A concrete class in this hierarchy represents onemathematical operation, which isperformed in its compute() function that returns the result of anoperation.Implement the Factory method design pattern using one factory classnamedOperationFactory so that an instance of a class in the Operationclass hierarchy can becreated based on the requested operation (+, -, *, /).Additionally, OperationFactory shouldalso be an implementation of Singleton.The user interface for the calculator should make use of fiveQPushbuttons, twoQDoubleSpinBoxes and one QLCDNumber as shown below:COS3711/Assignment 2/20225QDoubleSpinBoxes allow user to enter numbers and QLCDNumber is fordisplaying the resultof the calculation. To use the calculator, the user should firstenter two numbers and then selectone of the four (+, -, *, /) buttons. The result of the operationis displayed in QLCDNumber. Thebutton clear is used to clear QDoubleSpinBoxes andQLCDNumber.Note the following: The signals emitted by the four buttons (+, -, *, /) should behandled in a single slot. The user interface code should make use of the Operation classhierarchy to get the resultof the requested operation. Handle overflow in QLCDNumber display appropriately. Handle division by 0 appropriately.
In This Exercise Using C And Qt 5 6 You Will Design A Simple Calculator With Four Basic Operations Namely Addition 1
In This Exercise Using C And Qt 5 6 You Will Design A Simple Calculator With Four Basic Operations Namely Addition 1 (118.33 KiB) Viewed 39 times
In this exercise, you will design a simple calculator with four basic operations, namely addition, subtraction, multiplication, and division. Implementation of this simple calculator should separate the code for user interface and mathematical operations. The code for performing mathematical operations should be designed using the following class hierarchy: Addition + compute(x : double, y: double): double Operation + compute(x : double, y: double): double Multiplication + compute(x: double, y: double): double ● Subtraction ● The Operation class hierarchy contains the logic for performing various mathematical operations. A concrete class in this hierarchy represents one mathematical operation, which is performed in its compute () function that returns the result of an operation. + compute(x: double, y: double): double + compute(x : double, y: double): double Implement the Factory method design pattern using one factory class named OperationFactory so that an instance of a class in the Operation class hierarchy can be created based on the requested operation (+, −, *, /). Additionally, Operation Factory should also be an implementation of Singleton. The user interface for the calculator should make use of five QPushbuttons, two QDoubleSpinBoxes and one QLCDNumber as shown below: Calc 0,00 0,00 Clear ; Division 0 0 X # 1 QDoubleSpinBoxes allow user to enter numbers and QLCDNumber is for displaying the result of the calculation. To use the calculator, the user should first enter two numbers and then select one of the four (+, −, *, /) buttons. The result of the operation is displayed in QLCDNumber. The button clear is used to clear QDoubleSpinBoxes and QLCDNumber. Note the following: The signals emitted by the four buttons (+, -, *, /) should be handled in a single slot. The user interface code should make use of the Operation class hierarchy to get the result of the requested operation. Handle overflow in QLCDNumber display appropriately. Handle division by 0 appropriately.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply