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
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
Get step-by-step solutions from verified subject matter experts
