questions. Share to Sell: Company JutaMillion Share Amount to sell: 1900 CurrentPrice: 5.5 Brokerage Rate: 0.42 Total Selling Price: 5472.864 Share to Sell: Company MajuMundur Share Amount to sell: 100 CurrentPrice: 1.5 Brokerage Rate: 0.42 Total Selling Price: 148.2872 Press any key to continue .... Figure 1 NOTE: Please take note of the following answer format for these structured questions. Please use only one white space for separating two words. For example class name: public class No white space between operator/keyword and two words. For example: assignment/arithmetic/dot operators: c=10.myObjx=25,myObj.myMethod() a. At line 20-line 25 in Program B1, write the second constructor that initializes all of the private instance variables of the class Stock by using this keyword. b. At line 28 - line 50, complete the accessor methods of the stock class. b. At line 51 - line 55 in Program B1, write a code to calculate the cost of the stock selling price. The cost of the stock selling price is given as Sale price = amount of share - (Brokerage Fees(BF) + SST(%) to BF +clearance fees + stamp duty) where amount of share = unit of share current price Brokerage Fees = brokerage rate amount of share Clearance Fees = clearance rate * amount of share stamp duty - 1 // Program B1 public class Stock private String stock Company private int unitShare; private double currentPrice; ho private double brokerRate; private double sstRate; private double clearRate; public Stock { stockCompany - unitshare=0; װ 12 13 14 currentPrice-0.0; 15 brokerRate=0.0; sstRate=0.0 16 clearRate=0.0
14 currentPrice=0.0; 15 brokerRate=0.0; 116 sstrate=0.0; 17 clearRate=0.0; ; 118 } 19 public Stock(String stock Company int unitShare, double currentPrice, double brokerRate, double 20 SSTRate, double clRate) { 21 22 EstockCompany 23 =unitShare; 24 25 EcurrentPrice; 26 = brokerRate; 27 28 sstRate=SSTRate; 29 clearRate=clRate; 30 31 } 32 33 public String getStockCompany { 34 35 36 } 37 38 39 public double getCurrentPrice) { 40 41 42 } 43 44 45 public double getUnitShare(0 { 46 47 48 } 49 50 public double getBrokerRate() { 51 52 53 } 54 155 56 public double calcSellStockCost() { 57 58 59 double brokerFees; double shareAmount : shareAmount= unitShare + currentPrice: brokerFees = shareAmount brokerRate/100; 160 61 62 163 64 65 66 } 67 68
C. From line 5 - line 15 in Program B2, complete the static method named displayinfo() to display the information of each item object and its costs. d. At line 20 - line 22 in Program B2, create two Stocks objects, stockl and stock2; and assign the values as shown in Figure 1. e. At line 24- line28 in Program B2, call a static method named displayinfo) that displays the information of each item object and its sum of the selling price earned by the investor //Program B2 public class TestStock{ 4 5 public static void displayinto s) 16 { 8 System.out.println("\n\nShare to Selli" 9 + "\nShare Amount to sell:" + "\nCurrent Price: lo + "\nBrokerage Rate:" + 1 12 + "\nTotal Selling Price:" + 13 114 15 } 16 17 public static void main(String[] args) { 18 119 20 21 22 23 24 25 26 27 28 29 30
Figure 1 is supposed to be the output of Program BI and B2. Program Bland B2 calculate the total cost of the stock selling price on the Kuala Lumpur Stock exchange (BSKL). Complete Program B1 and B2 by answering the following Figure 1 is supposed to be the output of Program BI and B2. Program Bland B2 calculate the total cost of the stock selli
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am