Write a program that prints all digits of a positive integer in reverse order. import java.util.Scanner; public class ReverseDigits { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); // TODO: Print the digits of n in reverse while (/* Your code goes here */) { /* Your code goes here */ System.out.print(digit); /* Your code goes here */ } System.out.println(); } }
Write a program that prints all digits of a positive integer in reverse order.
import java.util.Scanner;
public class ReverseDigits
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
// TODO: Print the digits of n in reverse
while (/* Your code goes here */)
{
/* Your code goes here */
System.out.print(digit);
/* Your code goes here */
}
System.out.println();
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
Write a program that prints all digits of any integer in reverse order.
import java.util.Scanner;
public class ReverseDigits
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
// TODO: Print the digits of n in reverse
/* Your code goes here */
if (n < 0)
{
/* Your code goes here */
}
else if (n == 0)
{
/* Your code goes here */
}
while (/* Your code goes here */)
{
/* Your code goes here */
}
System.out.print(/* Your code goes here */);
System.out.println();
}
}