It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Own code:Output Confusing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Own code:Output Confusing" Watch "Own code:Output Confusing" New topic

Own code:Output Confusing

Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432

Input: 3
Output :how many children do you have 51
your allowance=3900
Input: 5
Output :how many children do you have 53
your allowance=3900
Input: 100
Output :how many children do you have 49
your allowance=14400
Please explain.

SCJP 6 | FB : Java Certifications-Help. | India Against Corruption
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4200

Take it one step at a time.

1) Print what you want the user to input.
2) Read the user input and parse it to an int.
3) Do the math.
4) Print your output message.

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
It is sorta covered in the JavaRanch Style Guide.
subject: Own code:Output Confusing
It's not a secret anymore!