Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##StockThing.py
- #Made by David Hunt
- #PsuedoCode:
- #int buyNumShares, buyPricePerShare, soldShares, soldPricePerShare, sbComm
- #int amountPayedForShares = buyNumShares * buyPricePerShare
- #int amountOfCommission = amountPayedForShares * sbComm
- #int totalMoneyPayed = amountPayedForShares + amountOfCommission
- #Display ("Joe payed a total of $" , amountPayedForShares, " for the shares")
- #Display ("Joe payed his stockbroker $",amountOfCommission, " for the buying commision")
- #Display ("Joe payed a total of $", totalMoneyPayed, " for this transaction.")
- #Display () - Blank space for output format
- #int soldAmount = soldShares * soldPricePerShare
- #int amountOfCommission = soldAmount * sbComm
- #int totalMoneySold = soldAmount - amountOfCommission
- #Display ("Joe sold his stock for $", soldAmount, " two weeks later.")
- #Display ("Joe payed his stockbroker $",amountOfCommission, " for the selling commision")
- #Display ("Joe sold his shares for ", totalMoneySold, " including the stockbroker commission")
- #Display ()
- #int amountMadeLost = (totalMoneySold - totalMoneyPayed)
- #if amountMadeLost > 0
- # print ("Joe earned a total of $", amountMadeLost ," from selling his shares and taking out the commision of the stockbroker.")
- #elseif amountMadeLost is 0
- # print ("Joe did not lose nor make anything. Hey, at least he didn't lose anything!")
- #else
- #print ("Joe lost a total of $", amountMadeLost ," from selling his shares and taking out the commision of the stockbroker.")
- ########################################
- ##The ability to alter any values to change resuls is in place.
- #Amount and the price per share when he buys
- buyNumShares = 1000
- buyPricePerShare = 32.87
- #Amount and the price per share when he sells
- soldShares = 1000
- soldPricePerShare = 33.92
- #stockbroker commision
- sbComm = 0.02
- ##determine and print the amount joe payed
- amountPayedForShares = buyNumShares * buyPricePerShare
- amountOfCommission = amountPayedForShares * sbComm
- totalMoneyPayed = amountPayedForShares + amountOfCommission
- ##Print results
- print ("Joe payed a total of $" , amountPayedForShares, " for the shares")
- print ("Joe payed his stockbroker $",amountOfCommission, " for the buying commision")
- print ("Joe payed a total of $", totalMoneyPayed, " for this transaction.")
- print ()
- ##determine and print amount joe made
- soldAmount = soldShares * soldPricePerShare
- amountOfCommission = soldAmount * sbComm
- totalMoneySold = soldAmount - amountOfCommission
- ##Print results
- print ("Joe sold his stock for $", soldAmount, " two weeks later.")
- print ("Joe payed his stockbroker $",amountOfCommission, " for the selling commision")
- print ("Joe sold his shares for ", totalMoneySold, " including the stockbroker commission")
- print ()
- #Determine the amount he made and if it is positive or not
- amountMadeLost = (totalMoneySold - totalMoneyPayed)
- ##Display results
- if amountMadeLost > 0:
- print ("Joe earned a total of $", amountMadeLost ," from selling his shares and taking out the commision of the stockbroker.")
- elif amountMadeLost == 0 :
- print ("Joe did not lose nor make anything. Hey, at least he didn't lose anything!")
- else :
- print ("Joe lost a total of $", amountMadeLost ," from selling his shares and taking out the commision of the stockbroker.")
Add Comment
Please, Sign In to add comment