To design a class-based solution to a problem using

Assignment Help Application Programming
Reference no: EM13346878

To design a class-based solution to a problem using multiple data structures.

The Problem:

Write a program to help an investor figure out which stocks to sell from his/her portfolio. In the USA, the government taxes income from investments. This is called capital gains tax. Your program will determine profit and loss on stock sales, using either of two different accounting methods:

LIFO: Last purchased is the first sold

FIFO: First purchased is the first sold.

To illustrate these methods, suppose you have the following transactions:

Stock Name

Date

Number of shares

Price per share

UMKC

June 1

100

45.50

UMKC

June 6

100

46.50

UMKC

June 15

100

48.50

UMKC

June 22

100

55.50

Now, let's say you want to sell 125 shares of UMKC stock. You can choose to sell either the oldest or the newest shares. Today's price is $54.00/share. Under the FIFO method, the 125 shares sold are considered to have cost $5712.50 (100 shares at $45.50 and 25 shares at $46.50), earning a profit of $1037.50 for reporting taxable income to the IRS. Under the LIFO method, the 150 shares sold cost $6762.50 (100 shares at $55.50 and 25 at $48.50), which means you will report a loss of $12.50 to the IRS.

The program will allow for the following activities:

1. Stock Purchase--add the number of shares and cost to the portfolio list for that stock in the portfolio. If current portfolio does not have the stock already in inventory, the stock is added to the stock list and the shares added to its inventory.

2. Stock Sale-- deletes the specified number or shares from the portfolio and generates a report ("report.txt") of the accounting method (FIFO, LIFO) that results in the minimum profit (or maximum loss). The method that produces the desired results is also noted as part of the output for this option. 
The report file should look like the following:

3.  Profit/Loss Report for Sale of UMKC

4.  FIFO method results in a profit of 1037.50

5.  LIFO method results in a loss of -12.50

6.  Profit/Loss Report for Sale of PCS

7. FIFO method results in a profit of 3250

8. LIFO method results in a profit of 3375

Input

Your program will read all transaction data from a file.

Each line of the transaction file will include

  • stock symbol
  • action to be taken (char 'B' or 'S' to indicate a buy or sell)
  • the number of shares bought or sold
  • the price paid or received.

Example file contents:

IBM B 100 100.00
PCS B 100 100.00
PCS B 75 95.00
IBM B 100 90.00
IBM S 150 95.00
CERN B 200 80.00
PCS S 150 120.00

Output

For all valid transactions, print the transaction to the output file(output3.txt). After each valid transaction, print the total holdings of the portfolio.

Sample output:

Transaction:  CERN  B    200      80.00

Total Holdings:

Name  #Shares  LIFO Value  FIFO Value

CERN      200     1600.00     1600.00

IBM        50     5000.00     4500.00

PSC        25     2500.00     2250.00

============================================

If a transaction lists a sale of a given stock which is either not in the portfolio, or there are not enough shares owned, then print the transaction to an error file.

Reference no: EM13346878

Questions Cloud

A new oncologist has joined the medical staff since 4 west : a new oncologist has joined the medical staff. since 4 west has been the admitting unit for oncology patients in the
Hon-a-chipnbsp microfluidics-based devices for : human-on-a-chipnbsp microfluidics-based devices for simulating physiology of individual organs or organ
To increase the awareness of monitoring and recording the : to increase the awareness of monitoring and recording the blood pressure of patientsto practice measuring blood
Prepare a marketing plan for one or two new products in : prepare a marketing plan for one or two new products in your own business andor another business in your country or
To design a class-based solution to a problem using : to design a class-based solution to a problem using multiple data structures.the problemwrite a program to help an
Implementation in matlab under windows to open a named pipe : implementation in matlab under windows to open a named pipe and to read data from the pipe an other program writes into
We have selected a case study from the university of hong : we have selected a case study from the university of hong kong wal-mart in china 2012. this is an updated case on
Part-1selecting array elements implement the following c : part-1selecting array elements implement the following c code in assembly language using the block-structured .if and
Purchased merchandise from abilene company for 6000 under : purchased merchandise from abilene company for 6000 under credit terms of 110 n30 fob destination invoice dated august

Reviews

Write a Review

Application Programming Questions & Answers

  In this project you will create an application to run in

in this project you will create an application to run in the amazon ec2 service and you will also create a client that

  Imagine that your company has decided to expand to the web

imagine that your company has decided to expand to the web. you want to reuse some data entry code that has been

  1 here is a short program it prints out the value of a

1. here is a short program. it prints out the value of a variable x. ernie and bert disagree about what will be printed

  If the user wants to read the input from a file then the

if the user wants to read the input from a file then the output will also go into a different file. if the user wants

  Question 1we are given the following knowledge base of

question 1we are given the following knowledge base of travel informationnbspbycaraucklandhamilton.

  Basic requirementsscreen one has three edittext views and

basic requirementsscreen one has three edittext views and one button.the edittext views allow you to enter a students

  Create a application using the mvc architecture no

create a application using the mvc architecture. no scripting elements are allowed in jsp

  Rtl sa is a company which develops bespoke solutions for

rtl sa is a company which develops bespoke solutions for the rubber industry. they produce both rubber compound which

  Design a program that models the worms behavior in the

design a program that models the worms behavior in the subsequent scenarioa worm is moving toward an apple. each time

  Problem build a class for a type called fractionnbspthis

problem build a class for a type called fraction.nbspthis class is used to show a ration of two integers.nbsp include

  Part - 1 object-oriented designwrite a program that allows

part - 1 object-oriented designwrite a program that allows an instructor to keep a grade book. each students has scores

  Soda vending machine designnbsp design a soda vending

soda vending machine designnbsp design a soda vending machine that can deliver three kinds of soda a b and c. allnbsp

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd