My program is supposed to ask the user to enter a dollar value from up to 100 dollars, and output the amount of bills and coins required to create that amount with the least change possible. I'm not completely finished, however when I test run the program and I enter values below 50, it doesnt seem to give me wrong info and negative numbers. Why is this happening? Thanks
import java.io.*; public class ChangeProgram { public static void main (String [] args) throws IOException { BufferedReader myInput = new BufferedReader (new InputStreamReader (System.in)); String inputA; double inputB = 0.0, input = 0.0, remainder = 0, remainderB = 0, remainderD = 0, remainderF = 0, remainderH = 0, remainderJ = 0, remainderL = 0, remainderN = 0, remainderP = 0, remainderR = 0; System.out.println("Please enter a dollar amount: "); inputA = myInput.readLine(); input = Double.parseDouble(inputA); System.out.println("\nAmount: \n"); if (input >= 50 || input < 100){ double answer = input / 50; double fifty = Math.floor(answer); System.out.println(fifty + " $50 bill(s)"); remainder = input - 50; } if(remainder >= 20 || remainder < 50){ double answerB = remainder / 20; double remainderA = Math.floor(answerB); System.out.println(remainderA + " $20 bill(s)"); double twenty = remainderA * 20; remainderB = remainder - twenty; } if(remainderB >= 10 || remainderB < 20){ double answerC = remainderB / 10; double remainderC = Math.floor(answerC); System.out.println(remainderC + " $10 bill(s)"); double ten = remainderC * 10; remainderD = remainderB - ten; } if(remainderD >= 5 || remainderD < 10){ double answerD = remainderD / 5; double remainderE = Math.floor(answerD); System.out.println(remainderE + " $5 bill(s)"); double five = remainderE * 5; remainderF = remainderD - five; } if(remainderF >= 2 || remainderF < 5){ double answerE = remainderF / 2; double remainderG = Math.floor(answerE); System.out.println(remainderG + " toonie(s)"); double two = remainderG * 2; remainderH = remainderF - two; } if(remainderH >= 1 || remainderH < 2){ double answerF = remainderH / 1; double remainderI = Math.floor(answerF); System.out.println(remainderI + " loonie(s)"); double one = remainderI * 1; remainderJ = remainderH - one; } if (remainderJ >= 0.25 || remainderJ < 1){ double answerG = remainderJ / 0.25; double remainderK = Math.floor(answerG); System.out.println(remainderK + " quarter(s)"); double quarter = remainderK * 0.25; remainderL = remainderJ - quarter; } if(remainderL >= 0.10 || remainderL < 0.25){ double answerH = remainderL / 0.10; double remainderM = Math.floor(answerH); System.out.println(remainderM + " dime(s)"); double dime = remainderM * 0.10; remainderN = remainderL - dime; } if(remainderN >= 0.05 || remainderN < 0.10){ double answerI = remainderN / 0.10; double remainderO = Math.floor(answerI); System.out.println(remainderO + " nickel(s)"); double nickel = remainderO * 0.10; remainderP = remainderN - nickel; } if (remainderP >= 0.01 || remainderP < 0.05){ double answerJ = remainderP / 0.01; double remainderQ = Math.floor(answerJ); System.out.println(remainderQ + " penny(ies)"); double penny = remainderQ * 0.01; remainderR = remainderP - penny; } } }