import java.text.NumberFormat;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Part2 {
public static void main(String []args) {
Scanner input = new Scanner(System.in);
NumberFormat money = NumberFormat.getCurrencyInstance();
DecimalFormat decimalformat = new DecimalFormat("##0; ##0");
double a, b, answer;
double nOnebills, nFivebills, nTenbills;
double nTwentybills, nFiftybills, nOnehundredbills;
double int nPenny, nNickle, nDime, nQuarter;
System.out.println("Please input the amount the customer owns.");
a = input.nextDouble();
System.out.println("Please input the amount the customer paid.");
b = input.nextDouble();
answer = a - b;
System.out.println("The amount of change given back to the customer "+
money.format(answer));
nOnehundredbills = (answer)/(100);
if (nOnehundredbills <= 0) {
System.out.println("The number of hundred dollar bills in your change is 0");
} else {
System.out.println("The number of hundred dollar bills in your change is "+ nOnehundredbills);
}
}
}
The output was this:
Please input the amount the customer owns.
100
Please input the amount the customer paid.
200
The amount of change given back to the customer ($100.00)
The number of hundred dollar bills in your change is 0
The 0 should be a 1 since 100 divided by 100 is 1 and 1 is not less than or equal to zero so it should have gone to the else statement.