Your program should prompt the user to input a single string that represents asequence of transactions. Use semicolon (‘;’) to separate the transactions in your input string. For example, your program should support the following input string:
“buy 100 share(s) at $20 each;buy 20 share(s) at $24 each;buy 200share(s) at $36 each;sell 150 share(s) at $30 each;buy 50share(s) at $25 each;sell 200 share(s) at $35 each;”
•The output of your program should be the total capital gain (or loss) for the entire sequence, using the FIFO protocol as explained in P-6.36. For instance, the output for the example input should be: 1070
•Consider using built-in Java classes, e.g., classes that implement the interface java.util.Queue

Project submission (using and Canvas)
-The names of all the team members should be included in the Java file.
-Only one student should submit the final team’s solution.
-Make the required changes in the code to submit your project using
oMerge all the code in a single java program ( Observe that main class should be called Main.
oRemove public from all class definitions.
oRemove package line.
oRemove any input/ output messages (including column titles in the output).
-Run the test cases prepared for this project by clicking the “Run Tests” link in Fix any errors.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

//Add here your code for any additional classes (if needed)
import java.util.ArrayDeque;
import java.util.Scanner;

class Main {
//Add here your code for any additional methods (if needed)

public static void main(String[] args) {
    Scanner s = new Scanner(;
    ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
    String transactions = s.nextLine();
    int net = 0;
    for (String transaction: transactions.split(";")) {
      String[] params = transaction.split("\\s");
      String type = params[0];
      int quantity = Integer.parseInt(params...

By purchasing this solution you'll be able to access the following files:
Solution.PNG and

for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats