Write a GUI program that calculates profit sharing for a number of investors. In other words, a number of people (or institutions) each invest an amount of money in some venture, and profit is earned. The program must calculate the share of the profit that each of the investors must be paid, which is proportional to the amount they invested. The program should input the amounts invested by each investor. (The program should not restrict the number of investors – it should be able to cope with any number.) It should then allow the user to specify the profit earned. Finally, the program should calculate and display the profits of each investor. For example, say three investors invest the following amounts (2 nd column). Each amount represents a percentage of the total investment (3rd column). If the profit amount is 15000.00, it should be shared proportionally (4 th column): 1 10000.00 50% 7500.0 2 4000.00 20% 03000.0 3 6000.00 30% 05000.0 The user interface should comprise of the following: • A push button to add an investor amount. When this is clicked, an input dialog should be displayed to enter a floating point value. • A text edit to display the investor amounts as well as the percentages of the total (thus far) that each amount represents. 15 COS2614/101 • A spin edit to specify the profit amount. • A push button to calculate and display the profits earned by each investor. These amounts should be displayed next to the investor amounts and percentages (i.e. in a final column, as illustrated above) in the same text edit. As indicated in the example above, each investment amount has a number associated with it (in the 1 st column) which is determined simply by the order in which the amounts are added. This represents the investor number. Implementation requirements: You must define and implement a class that inherits from QList to store the amounts and calculate the profit sharing. The class should have the following member functions: • addAmount() takes a double value representing an investment amount as parameter. It merely appends the amount to the list of amounts. • setProfit() takes a double value representing the total profit amount and stores it in a data member. • totalInvestment() returns the sum of all the investment amounts currently stored in the class. • percentage() takes an integer representing the investor number as parameter. It returns the percentage that the corresponding investment amount represents of the total of all investments. • share() takes an integer representing the investor number as parameter. It returns the share of the profit earned by the investor. This class represents the model. You must define and implement a class that inherits from QDialog for the user interface. This class represents the view. In other words, you must separate the model from the view. The model should not refer to objects in the view, and the view should not directly manipulate values in the model or make calculations on them. The view code may only access the model through member functions provided by the model
#Sales Offer!| Get upto 25% Off: