Question: Please use java. and below is the test code. @Test public void Task2Simple(){ assertEquals(QNPPP, Lab1.printChange(33)); } @Test public void Task3Simple(){ // assertEquals(PPPNQ, Lab1.printChangeReversed(33)); } Task



Please use java.
and below is the test code.
@Test public void Task2Simple(){ assertEquals("QNPPP", Lab1.printChange(33)); } @Test public void Task3Simple(){ // assertEquals("PPPNQ", Lab1.printChangeReversed(33)); }
Task 2 Write a function that gives change, i.e. it takes an amount as argument, and it prints out P's, N's, D's, and Q's - one for each penny (1 cent), nickle (5 cent), dime (10 cent) and quarter ( 25 cent) it gives out. Ex: If Amount is 33 , it would print out: QNPPP Your function should be recursive, and here's some simple rules to help you (let A be the amount you need change for): 1) If A is 0 , don't give anything! 2) If A>0, give out one of the largest denomination not exceeding A, then make change for the remaining amount. Task 3 In the previous task, the output was ordered from the highest value coin to lowest value coin. Change the above function to display from lowest value coin to highest value coin. Ex: If Amount is 33 , it would print out: PPPN
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
