Cindy uses the services of a brokerage firm to buy and sell stocks. The firm charges 1.5% service charges on the total amount for each transaction -- buy or sell. When Cindy sells stocks, she would...

1 answer below »

Cindy uses the services of a brokerage firm to buy and sell stocks. The firm charges 1.5% service charges on the total amount for each transaction -- buy or sell.


When Cindy sells stocks, she would like to know if she gained or lost on a particular investment. Write a program that reads in the number of shares sold, the purchase price of each share, and the selling price of each share. Use a file to get this information. The program outputs to a file the amount invested, the total service charges, amount gained or lost, and the amount received after selling the stock.


The program needs to be written in Python.





Answered 1 days AfterJul 05, 2021

Answer To: Cindy uses the services of a brokerage firm to buy and sell stocks. The firm charges 1.5% service...

Aditya answered on Jul 07 2021
136 Votes
def main():
data = []
with open('data.txt') as file:
data = file.readlines()
number_of_shares = int(data[0])
buy_price = float(data[1])
sell_price = float(data[2])
total_buy_price = number_of_shares * buy_price
tax = 0.015 * total_buy_price
total_buy...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here