Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Main {
- public static void main(String[] args) {
- double stock = 1000;
- double boughtPerShare = 0.3287;
- double commission = 0.02;
- double boughtCommission;
- double boughtPerStock;
- double moneyBought;
- double soldPerShare = 0.3392;
- double soldCommission;
- double soldPerStock;
- double moneySold;
- double profit;
- boughtPerStock = (stock * boughtPerShare) * 1000; // money paid for the stock
- System.out.println("The amount of money Joe paid for the stock: $" + boughtPerStock);
- boughtCommission = boughtPerStock * commission; // 2% for the broker
- System.out.println("The amount of commission Joe paid to broker when he bought the stock: $" + boughtCommission);
- moneyBought = boughtPerStock - boughtCommission; // money paid - commission
- soldPerStock = (stock * soldPerShare) * 1000; // money earned from the stock
- System.out.println("The amount that Joe sold the stock: $" + soldPerStock);
- soldCommission = soldPerStock * commission; // 2% for the broker
- System.out.println("The amount of commission Joe paid to broker when he sold the stock: $" + soldCommission);
- moneySold = soldPerStock - soldCommission; // money earned - commission
- profit = moneySold - moneyBought; // difference between money earned and money bought
- System.out.println(profit);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment