Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java class called CoinStack.java, which implements CoinStackInterface. Write your application named CoinStackApp.java that read coins (three data files are provided for testing purpose):

Write a java class called CoinStack.java, which implements CoinStackInterface. Write your application named CoinStackApp.java that read coins (three data files are provided for testing purpose): Construct 4 stacks (for penny, nickel, dime, and quarter stack), read coins from the data file then push to their corresponding stacks. For example, if the value is 10, then you need to push that coin to dime stack.

Use the static method print in the PrintCoinStacks class to print sorted coins. The print method takes 4 CoinStackInterface as its arguments. The signature of this method is as follows: print(CoinStackInterface, CoinStackInterface , CoinStackInterface ,CoinStackInterface );

Here is a sample output:

Here is a sample output:

| | | | | | | |

| | | | | | | |

| | | | | | | |

| | | | | | | |

| | | | | | | |

| | |-----| | | | |

| | |-----| | | | |

| | |-----| | | | |

| | |-----| |----| | |

| | |-----| |----| | |

| | |-----| |----| |------|

| | |-----| |----| |------|

| | |-----| |----| |------|

|----| |-----| |----| |------|

|----| |-----| |----| |------|

Given information:

public class Coin{

int value;

Coin next;

public Coin(int value){

this.value=value;

}

public void setLink(Coin coin){

this.next=coin;

}

public Coin getLink(){

return next;

}

public int getValue(){

return value;

}

}

Data file:

5 10 25 1 10 1 25 1 10 25 1 5 10 10 10 10 10 1 1 5 25 25 25 10 10 5 25 1 10 1 1 5 1 25 10 25 25 1 25 10 5 10 25 25 10 25 10 5 5 25 10 25 5 25 5 5 5 5 10 5 10 5 10 1 10 5 25 5 10 25 10 1 5 25 1 25 10 5 10 1 25 5 5 1 1 10 5 1 25 25 1 5 10 1 5 1 5 10 10 1

The program should read this file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago