Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Question mark "?" appears in output

843810Mar 26 2006 — edited Mar 26 2006
Output:

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 23 2006
Added on Mar 26 2006
1 comment
1,336 views