Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Enter cost of item (in cents): 123 Price of item must be multiple of 5 cents. En

ID: 3619068 • Letter: E

Question

Enter cost of item (in cents): 123 Price of item must be multiple of 5 cents. Enter cost of item (in cents): 100 Current balance: 0 Enter coin value (200, 100, 25, 10, 5): 200 You paid 200 cents for something that cost 100 cents. Giving 100 cents in change. Quarters: 4 Dimes : 0 Nickels : 0 Enter cost of item (in cents): 100 Current balance: 0 Enter coin value (200, 100, 25, 10, 5): 23 Invalid coin. Current balance: 0 Enter coin value (200, 100, 25, 10, 5): 12 Invalid coin. Current balance: 0 Enter coin value (200, 100, 25, 10, 5): 25 Current balance: 25 Enter coin value (200, 100, 25, 10, 5): 200 You paid 225 cents for something that cost 100 cents. Giving 125 cents in change. Quarters: 5 Dimes : 0 Nickels : 0

Explanation / Answer

please rate - thanks import java.util.*; public class change {public static void main(String[] args) {int cost,paid=0,change,n,balance=0; Scanner input=new Scanner(System.in); System.out.println("Enter cost of item (in cents):"); cost=input.nextInt(); while(cost%5!=0)    {System.out.println("Cost of item must be multiple of5 cents.");    System.out.println("Enter cost of item (incents):");     cost=input.nextInt();    } while(balance=0)      {System.out.println("You paid "+balance+"cents for something that cost "+cost+" cents. ");      System.out.println("Giving "+change+"cents in change.");       n=change/25;       System.out.println("Quarters: "+n);       change%=25;       n=change/10;       System.out.println("Dimes   :"+n);      n=change%10;       System.out.println("Nickels : "+n);      } } }