This is an additional assignment from the chapter on the Java Collections Framework. Suppose you buy 100 shares of a sto

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

This is an additional assignment from the chapter on the Java Collections Framework. Suppose you buy 100 shares of a sto

Post by answerhappygod »

This is an additional assignment from the chapter on the JavaCollections Framework.
Suppose you buy 100 shares of a stock at $12 per share, thenanother 100 at $10 per share, then you sell 150 shares at $15. Youhave to pay taxes on the gain, but exactly what is the gain? In theUnited States, the FIFO rule holds: You first sell all shares ofthe first batch for a profit of $300, then 50 of the shares fromthe second batch, for a profit of $250, yielding a total profit of$550.
Write a program that can make these calculations for arbitrarypurchases and sales of shares in a portfolio. The user enterscommands buy symbol quantity price, sell symbol quantity price(which causes the gain on that transaction to be displayed), andquit. Hint: Keep a Map<String, Queue> that manages a separatequeue for each stock symbol.
Use the included templates for the program in the included zipfile. You do not need to add any additional methods other than whatare included. There is a sample of an input script so you can seehow I may test your program. It ends with the extension .in, but itis just a sample. Be sure to fully test the program beforesubmitting it. I should not be able to crash it.
This Is An Additional Assignment From The Chapter On The Java Collections Framework Suppose You Buy 100 Shares Of A Sto 1
This Is An Additional Assignment From The Chapter On The Java Collections Framework Suppose You Buy 100 Shares Of A Sto 1 (66.82 KiB) Viewed 40 times
Assignment 10 Directions This is an additional assignment from the chapter on the Java Collections Framework. Suppose you buy 100 shares of a stock at $12 per share, then another 100 at $10 per share, then you sell 150 shares at $15. You have to pay taxes on the gain, but exactly what is the gain? In the United States, the FIFO rule holds: You first sell all shares of the first batch for a profit of $300, then 50 of the shares from the second batch, for a profit of $250, yielding a total profit of $550. Write a program that can make these calculations for arbitrary purchases and sales of shares in a portfolio. The user enters commands buy symbol quantity price, sell symbol quantity price (which causes the gain on that transaction to be displayed), and quit. Hint: Keep a Map<String, Queue> that manages a separate queue for each stock symbol. Use the included templates for the program in the included zip file. You do not need to add any additional methods other than what are included. There is a sample of an input script so you can see how I may test your program. It ends with the extension .in, but it is just a sample. Be sure to fully test the program before submitting it. I should not be able to crash it.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply