Question: Proof my code, Java language My code: package demo; //function to count and print currency notes public class Shopkeeper{ public static void main (String args[])

Proof my code, Java language Proof my code, Java language My code: package demo; //function to count

My code:

package demo;

//function to count and print currency notes public class Shopkeeper{ public static void main (String args[]) { int[] notes = new int{5, 1}; int[] noteCounter = new int[2]; for(int i = 0; i = notes[i]) { if(amount >= notes[i]) { noteCounter[i] = amount / notes[i]; amount = amount - noteCounter[i]; amount = amount - noteCounter[i] * notes[i]; } } //Print notes System.out.println("Currency count -> "); for(int i = 0; i Problem Statement You have x number of $5 notes and y number of $1 notes. You want to purchase an item for amount z. The shopkeeper wants you to provide exact change. You want to pay using a minimum number of notes. How many $5 notes and $1 notes will you use? Implement a program to find out how many $5 notes and $1 notes will be used. If an exact change is not possible, then display-1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!