Enter an integer: 20
20 plus 10 is 30.
20 plus 100 is 120.
20 plus 1000 is 1020.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Enter an integer:");
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for (int i = 10; i < 10000; i *= 10) {
System.out.println(n + " plus " + i + " is " + (n + i));
}
}
}
Comments
Leave a comment