W2
Write of program in Java that accepts a single digit number n. Frame and print the
numbers in two digits, three digits and four digits by using only n as digits of the
numbers.
Sample Input: 5
Sample output: 55, 555, 5555
Answers
Answered by
2
JAVA programming that accepts a single digit number n.
The following is the JAVA programming that gives the required output asked in the question:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the number :") ;
int n;
n = in.nextInt();
System.out.printf("%d%d, %d%d%d, %d%d%d%d",n,n,n,n,n,n,n,n,n);
}
}
Similar questions