REC8 JAVA Programming Java is the #1 programming language and development platform. It reduces costs, shortens developme

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

REC8 JAVA Programming Java is the #1 programming language and development platform. It reduces costs, shortens developme

Post by answerhappygod »

REC8 JAVA Programming
Java is the #1 programming language and development platform. Itreduces costs, shortens development timeframes, drives innovation,and improves application services. With millions of developersrunning more than 51 billion Java Virtual Machines worldwide, Javacontinues to be the development platform of choice for enterprisesand developers.
Rec8 Java Programming Java Is The 1 Programming Language And Development Platform It Reduces Costs Shortens Developme 1
Rec8 Java Programming Java Is The 1 Programming Language And Development Platform It Reduces Costs Shortens Developme 1 (48.59 KiB) Viewed 29 times
Rec8 Java Programming Java Is The 1 Programming Language And Development Platform It Reduces Costs Shortens Developme 2
Rec8 Java Programming Java Is The 1 Programming Language And Development Platform It Reduces Costs Shortens Developme 2 (36.09 KiB) Viewed 29 times
REFERENCE CODE
QUEUE
public interface Queue<E> { /** * Returns the number of elements in the queue. * @return number of elements in the queue */ int size();
/** * Tests whether the queue is empty. * @return true if the queue is empty, falseotherwise */ boolean isEmpty();
/** * Inserts an element at the rear of the queue. * @param e the element to be inserted */ void enqueue(E e);
/** * Returns, but does not remove, the first element ofthe queue. * @return the first element of the queue (or null ifempty) */ E first();
/** * Removes and returns the first element of thequeue. * @return element removed (or null if empty) */ E dequeue();}
STACK
public interface Stack<E> {
/** * Returns the number of elements in the stack. * @return number of elements in the stack */ int size();
/** * Tests whether the stack is empty. * @return true if the stack is empty, falseotherwise */ boolean isEmpty();
/** * Inserts an element at the top of the stack. * @param e the element to be inserted */ void push(E e);
/** * Returns, but does not remove, the element at the topof the stack. * @return top element in the stack (or null ifempty) */ E top();
/** * Removes and returns the top element from thestack. * @return element removed (or null if empty) */ E pop();}
Look at 6.36 in the attachment to define the term capital gain and its calculation. Your input format can just be Txn type, qty, price. For Example: B,20,15 - Bought 20 shares at 15 S, 10, 12 - Sold 10 shares at 12 Use a Queue ADT to do the FIFO implementation described and then in a different class use a Stack with the LIFO method. Use the book classes to support the use of a Queue and Stack. Print out the capital gain after each Sold transaction. Test Data: B,30,100 B,40,110 S,50, 120 Capital Gain 1 = 800 (FIFO), 600 (LIFO) S,20,125 Capital Gain 2 : 300(FIFO), 500(LIFO) In this case, with rising prices, LIFO pushes tax liability out in the future. Submit a zipped folder of your Eclipse project
P-6.36 When a share of common stock of some company is sold, the capital gain (or, sometimes, loss) is the difference between the share's selling price and the price originally paid to buy it. This rule is easy to understand for a single share, but if we sell multiple shares of stock bought over a long period of time, then we must identify the shares actually being sold. A standard accounting principle for identifying which shares of a stock were sold in such a case is to use a FIFO protocol--the shares sold are the ones that have been held the longest (indeed, this is the default method built into several personal finance software packages). For example, suppose we buy 100 shares at $20 each on day 1, 20 shares at $24 on day 2, 200 shares at $36 on day 3, and then sell 150 shares on day 4 at $30 each. Then applying the FIFO protocol means that of the 150 shares sold, 100 were bought on day 1, 20 were bought on day 2, and 30 were bought on day 3. The capital gain in this case would therefore be 100 10+20-6+30-(-6), or $940. Write a program that takes as input a sequence of transactions of the form "buy x share(s) at $y each" or "sell x share (s) at $y each," assuming that the transactions occur on consecutive days and the values x and y are integers. Given this input sequence, the output should be the total capital gain (or loss) for the entire sequence, using the FIFO protocol to identify shares.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply