Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

Members have full access to the forums. Advertisements are removed for registered users.

# Thread: IB programming question

1. ## IB programming question

Hello, can anyone please help me with the following? Id greatly appreciate it Write a program which accepts 4 digit number (at least two of the digits are different) e.g. the number cannot have all the digits same. (e.g. 7029 is a valid number but not 8888). You may even accept numbers with less than 4 digits but compensate it with extra zeroes accordingly. e.g. if user input is 1 then you should accept it as 0001 which is valid input for this task.
i. Now generate a 4 digit number (smallNum) from the user input such that the digits are arranged in ascending order (i.e. in the above example it would be 0279)
ii. Now generate a 4 digit number (largeNum) from the user input such that the digits are arranged in descending order (i.e. in the above example it would be 9720)
iii. Now, find another number (num) which is num = largeNum - smallNum
iv. printout value of num.
v. Repeat from step i. (To start with, there is no terminating condition for this repeat structure).

Observe the pattern and figure out what happens with different numbers?
Once you find the pattern, write the terminating condition for the loop in comment.
Make sure that you check if the input number is at most 4 digits and at least 2 digits are different. You may assume that the user inputs are always positive integers.

Hello, can anyone please help me with that one? Id appreciate it greatly Write a program which accepts 4 digit number (at least two of the digits are different) e.g. the number cannot have all the digits same. (e.g. 7029 is a valid number but not 8888). You may even accept numbers with less than 4 digits but compensate it with extra zeroes accordingly. e.g. if user input is 1 then you should accept it as 0001 which is valid input for this task.
i. Now generate a 4 digit number (smallNum) from the user input such that the digits are arranged in ascending order (i.e. in the above example it would be 0279)
ii. Now generate a 4 digit number (largeNum) from the user input such that the digits are arranged in descending order (i.e. in the above example it would be 9720)
iii. Now, find another number (num) which is num = largeNum - smallNum
iv. printout value of num.
v. Repeat from step i. (To start with, there is no terminating condition for this repeat structure).

Observe the pattern and figure out what happens with different numbers?
Once you find the pattern, write the terminating condition for the loop in comment.
Make sure that you check if the input number is at most 4 digits and at least 2 digits are different. You may assume that the user inputs are always positive integers.  Reply With Quote

2. ## Re: IB programming question

What have you tried?
Post your current code with any specific java programming questions you have.

Be sure to wrap your code with code tags:

[code]
**YOUR CODE GOES HERE**
[/code]

to get highlighting and preserve formatting.  Reply With Quote