Search:

Type: Posts; User: javapenguin

Search: Search took 0.08 seconds.

  1. Thread: Recursion

    by javapenguin
    Replies
    12
    Views
    2,522

    Re: Recursion

    For n = 1234;

    1234 /10 = 123

    123/10 = 12;

    12%10 = 2;

    123%10 = 3;
  2. Thread: Recursion

    by javapenguin
    Replies
    12
    Views
    2,522

    Re: Recursion

    What does that mean? Does he mean that I'm supposed to take it in like this:

    int n = console.nextInt();

    or, like I fear:

    make it part of args[] somehow?

    ---------------------------------
  3. Thread: Recursion

    by javapenguin
    Replies
    12
    Views
    2,522

    Re: Recursion

    public void printDigits(int n)
    {

    if (n < 0)
    {
    JOptionPane.showMessageDialog(null, "Hey, you can't have a negative value!", "No negatives please.", JOptionPane.ERROR_MESSAGE);
    return;
    }
    if...
  4. Thread: Recursion

    by javapenguin
    Replies
    12
    Views
    2,522

    Re: Recursion

    I know what it should display, but even if I can figure out how to get it to print, it'll print backwards.

    I can store the values in an Integer ArrayList, but I still have no clue how to do this
    ...
  5. Thread: Recursion

    by javapenguin
    Replies
    12
    Views
    2,522

    Ok, so I can get it to print it, but it'll print backwards.

    public void printDigits(int n)
    {
    if (0<=n<=9)
    int x = n;
    while (x/10 !=0)
    {
    x = x /10;


    }
  6. Thread: Recursion

    by javapenguin
    Replies
    12
    Views
    2,522

    Re: Recursion

    Ok, I figured out how to get it, but now it'll print it backwards, and I want it forwards.

    305

    305%10 = 5;

    305/10 = 30;

    30%10 = 0;
  7. Thread: Recursion

    by javapenguin
    Replies
    12
    Views
    2,522

    Re: Recursion

    I always wondered what a modulo was. However, yeah, I knew about the % operator.

    2%1 = 0;

    1%2 = 1;

    I did realize that using the % operator would work if I did something like 300.
    ...
  8. Thread: Recursion

    by javapenguin
    Replies
    12
    Views
    2,522

    Recursion

    I'm supposed to get it to take an int number and print it out one character at a time(one per line) and no, I'm not allowed to turn it into a String and use getCharAt(int x). I have to do it...
Results 1 to 8 of 8