Question mark "?" appears in output
843810Mar 26 2006 — edited Mar 26 2006Output:
No. of quarters: 4
No. of dimes: ? 10
No. of nicks: ? 20
No. of pennies: ? 100
Total amount is $4.0.
Code
public class CountChange {
public static void main(String [] args) {
int qrtrs, dimes, nicks, penns;
double total;
System.out.print("\nNo. of quarters: ");
qrtrs = TextIO.getInt();
System.out.print("No. of dimes: ");
dimes = TextIO.getInt();
System.out.print("No. of nicks: ");
nicks = TextIO.getInt();
System.out.print("No. of pennies: ");
penns = TextIO.getInt();
total = qrtrs*0.25 + dimes*0.10 + nicks*0.05 + penns*0.01;
System.out.print("Total amount: $");
System.out.println(total);
}
}
Correction
Replace getInt() with getlnInt()
Question
Why does "?" appear in the output? And why does it go away with getlnInt()?
Thanks