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.

Results 1 to 2 of 2

Thread: IB programming question

  1. #1
    Junior Member
    Join Date
    Feb 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Game Programming Question?
    By toofast88 in forum Android Development
    Replies: 1
    Last Post: March 21st, 2012, 07:34 AM
  2. programming question
    By codeTillMorning in forum Member Introductions
    Replies: 1
    Last Post: March 5th, 2012, 11:54 AM
  3. Replies: 0
    Last Post: December 12th, 2011, 03:17 PM
  4. Help in programming question. Bluej complier
    By Rads23 in forum What's Wrong With My Code?
    Replies: 12
    Last Post: August 3rd, 2011, 09:12 PM