... output error }}Using JUnit, you move the code in main(...) to a test method:1 2 3 4 5 6 import junit.framework.TestCase;public class TestPay extends TestCase { public void testAll() throws Exception { ... here is the code from the main method above }}in testAll() you can use some methods such as assert and fail to simplify testing.