Question

PsuedoCode into Python code

Prompt the user for the starting balance and store it in a variable called balance.

Prompt the user for the number of trades to perform and store it in num_trades.

Using num_trades, set up a for-loop and for each trade do:

if this is the first iteration of the loop:

Prompt the user for the number of shares to buy and store it in num_shares.

else:

Prompt the user for the type of trade that he/she wants to perform and store it in action.

Prompt the user for the number of shares to buy/sell and store it in num_shares.

if the action is “buy”:

Prompt the user for the price-per-share and store it in price_per_share.

Calculate the transaction amount and store it in transaction_amount

Print the number of shares, price-per-share, and the total cost of the trade.

Update the balance (subtract the transaction_amount from the the balance)

Update cumulative shares owned

Update cumulative shares bought

Otherwise:

Prompt the user for the price-per-share and store it in price_per_share.

Calculate the transaction amount and store it in transaction_amount

Print the number of shares, price-per-share, and the total cost of the trade.

Update the balance

Update cumulative shares owned

Update cumulative shares sold

Print appropriate statistics

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
PsuedoCode into Python code
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Write a code using loop and flag function in python jupitior notebook: Ask the user for...

    Write a code using loop and flag function in python jupitior notebook: Ask the user for the number of items they bought. Also ask the price of each item they bought and quantity purchased. Display the total amount they owe. Ask the user for a number n. Calculate 1+2+3+….+n. Ask the user for a number n. Calculate 1*2*3*…*n. Ask the user for number of rows (r) and columns (c). Print * for r rows and c columns. Ask the user...

  • I need help with using the infile and outfile operations in C++... Here's my assignment requirements:...

    I need help with using the infile and outfile operations in C++... Here's my assignment requirements: Assignment: 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 allows Cindy to read input from a file called Stock.txt: 1. The...

  • Write a complete Java program called "AtmSimDoLoop" (without the quotation marks) according to the following specifications....

    Write a complete Java program called "AtmSimDoLoop" (without the quotation marks) according to the following specifications. It should use a do-while loop to prompt the user with the following starting prompt (without the horizontal lines) until the user enters 4 to quit. The program should start with an initial account balance, which you can set to any legitimate double value. Prompt the user with the following prompt (without the horizontal lines). Enter the number of your desired transaction type. Deposit...

  • (PYTHON) Stock Transaction Program Last month Joe purchased some stock from StockTrade.   1. Write a function(s)...

    (PYTHON) Stock Transaction Program Last month Joe purchased some stock from StockTrade.   1. Write a function(s) to allow the user to input the followings: ·The name of the stock ·Number of shares Joe bought · Stock purchase price · Stock selling price ·Broker commission 2. Write function(s) to calculate: and: · The amount of money Joe paid for the stock (number of shares bought * purchase price) · The amount of commission Joe paid his broker when he bought the...

  • Suppose you bought 100 shares of IBM at $200 per share. What is the maximum loss...

    Suppose you bought 100 shares of IBM at $200 per share. What is the maximum loss if you place a stop-loss order at $180? Your Answer: Answer Question 10 (1 point) Here is some price information in Fincorp stock. Suppose that Fincorp trades in a dealer market. Bid 55.25 Asked 55.50 Suppose you have submitted an order to your broker to buy at market. What will happen? The trade will be executed at $55.50 The trade will not be executed...

  • Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================")...

    Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================") print(" Baseball Team Manager") print("MENU OPTIONS") print("1 - Calculate batting average") print("2 - Exit program") print("=====================================================================")    def convert_bat(): option = int(input("Menu option: ")) while option!=2: if option ==1: print("Calculate batting average...") num_at_bats = int(input("Enter official number of at bats: ")) num_hits = int(input("Enter number of hits: ")) average = num_hits/num_at_bats print("batting average: ", average) elif option !=1 and option !=2: print("Not a valid...

  • Write a program in Python that computes the interest accrued on an account. You can modify...

    Write a program in Python that computes the interest accrued on an account. You can modify the “futval.py” program given in Chapter 2 to accomplish it. Your program should use a counted loop rather than a formula. It should prompt the user to enter the principal amount, the yearly interest rate as a decimal number, the number of compounding periods in a year, and the duration. It should display the principal value at the end of the duration. To compute...

  • Write an application that queries the user for the following information about a stock transaction and...

    Write an application that queries the user for the following information about a stock transaction and then displays the net gain or loss on the transaction. Number of shares bought and sold (this is one number not two) Purchase price per share Purchase commission as a double (for example, 2% commission would be 0.02) Sale price per share Sale commission as a double (for example, 2% commission would be 0.02) You must allow the user to enter the values. However...

  • P2-2 (similar to) Question Help Transaction costs In late December you decide, for tax purposes, to...

    P2-2 (similar to) Question Help Transaction costs In late December you decide, for tax purposes, to sell a losing position that you hold in Twitter, which is listed on the NYSE, so that you can capture the loss and use it to offset some capital gains, thus reducing your taxes for the current year. However, since you still believe that Twitter is a good long-term investment, you wish to buy back your position in February the following year. To get...

  • Problem Statement Last month Tian purchased some stock in Acme Software, Inc. Here are the details...

    Problem Statement Last month Tian purchased some stock in Acme Software, Inc. Here are the details of the purchase:  The number of shares that Tian purchased was 1,000  When Tian purchased the stock, he paid $33.92 per share  Tian paid his stockbroker a commission that amounted to 2% of the amount he paid for the stock. One week later, Tian sold the stock. Here are the details of the sale: The number of shares sold was 1,000...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT