I been working on a program for class, and I finished it but I was wondering if I could put the code into a while statement to make it easier to read. If it's possible, can someone show me how?
Code:
import java.util.Scanner;
public class Problem3 {
//*** User input amount then print out amount in fewest number of bills
public static void main(String[] args) {
Scanner keyboard=new Scanner(System.in);
int amount;
int twenty;
int ten;
int five;
int one;
System.out.print("Enter amount: ");
amount=keyboard.nextInt();
twenty = amount/20;
amount = amount%20;
System.out.println("$20 dollar bills: " + twenty);
ten = amount/10;
amount = amount%10;
System.out.println("$10 dollar bills: " + ten);
five = amount/5;
amount = amount%5;
System.out.println("$5 dollar bills: " + five);
one = amount/1;
amount = amount%1;
System.out.println("$1 dollar bills: " + one);
}
}
Comment