For n = 1234;
1234 /10 = 123
123/10 = 12;
12%10 = 2;
123%10 = 3;
Type: Posts; User: javapenguin
For n = 1234;
1234 /10 = 123
123/10 = 12;
12%10 = 2;
123%10 = 3;
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?
---------------------------------
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...
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
...
public void printDigits(int n)
{
if (0<=n<=9)
int x = n;
while (x/10 !=0)
{
x = x /10;
}
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;
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.
...
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...