File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Programming-Challenges/Fundamentals
out/production/Programming-Challenges/com/challenges Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ Kathryn bought 600 shares of stock at a price of $21.77 per share.
3
+ She must pay her stockbroker a 2 percent commission for the transaction.
4
+ Write a program that calculates and displays the following:
5
+ • The amount paid for the stock alone (without the commission)
6
+ • The amount of the commission
7
+ • The total amount paid (for the stock plus the commission)
8
+ */
9
+
10
+ package com .challenges ;
11
+
12
+ public class StockCommission {
13
+ public static void main (String [] args ) {
14
+
15
+ // Declare Variables
16
+
17
+ int noOfShares = 600 ;
18
+ final double STOCK_PRICE = 21.77 ;
19
+ final double COMMISSION_PERCENT = 0.02 ;
20
+ double totalStockAmt ;
21
+ double totalCommissionAmt ;
22
+ double totalAmt ;
23
+
24
+ totalStockAmt = noOfShares * STOCK_PRICE ;
25
+ totalCommissionAmt = totalStockAmt * COMMISSION_PERCENT ;
26
+ totalAmt = totalStockAmt + totalCommissionAmt ;
27
+
28
+ System .out .println ("The amount paid for the stock (without commission: " + totalStockAmt );
29
+ System .out .println ("The amount of commission: " + totalCommissionAmt );
30
+ System .out .println ("Total Amount Paid: " + totalAmt );
31
+
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments