Can someone please help me solve this? The number should be variable and not constant. The output should be:
Timestamping In 6 Digit 8 5 6 3 0 1 Average In 6 Digit 9 8 7 6 5 2
class Timestamp1 extends Average1
{
public static void main (String args[]) {
int i = 103658;
int j = 10;
int k = i % j;
System.out.println(" Timestamping In 6 Digit " );
System.out.println(" " + k);
int o = 10365;
int p = 10;
int q = o % p;
System.out.println(" " + q);
int l = 1036;
int m = 10;
开发者_JAVA百科 int n = l % m;
System.out.println(" " + n);
int r = 103;
int s = 10;
int t = r % s;
System.out.println(" " + t);
int u = 10;
int v = 10;
int w = u % v;
System.out.println(" " + w);
int x = 1;
int y = 10;
int z = x % y;
System.out.println(" " + z);
class Average1 extends Timestamp1 {
public void main() {
int i = 256789;
int j = 10;
int k = i % j;
System.out.println(" Average In 6 Digit ");
System.out.println(" " + k);
int o = 25678;
int p = 10;
int q = o % p;
System.out.println(" " + q);
int l = 2567;
int m = 10;
int n = l % m;
System.out.println(" " + n);
int r = 256;
int s = 10;
int t = r % s;
System.out.println(" " + t);
int u = 25;
int v = 10;
int w = u % v;
System.out.println(" " + w);
int x = 2;
int y = 10;
int z = x % y;
System.out.println(" " + z);
}
}
}
}
If you just want to reverse a number then here you go
public String reverseNum(Integer i)
{
return new StringBuilder(i.toString()).reverse();
}
What do you really want to do? Print two integer numbers reversed? Then you should say so.
public static String reverseDigits(int i) {
StringBuilder sb = new StringBuilder();
sb.append(i);
sb.reverse();
return sb.toString();
}
...
System.out.println(reverseDigits(1234567));
...
精彩评论