Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a java program which: 1. Asks the user to enter a positive integer greater

ID: 3806130 • Letter: W

Question

Write a java program which:

1. Asks the user to enter a positive integer greater than 0

2. Validates that the entry is a positive integer

3. Outputs the digits in reverse order with a space separating the digits

4. Outputs the even digits not in reverse order with a space separating the digits (consider zero to be even)

5. Outputs the odd digits not in reverse order with a space separating the digits

6. Allows user is to repeat/continue the program as many times as he/she wants

7. Keeps a record in a txt file named outDataFile.txt with the history of all numbers entered and the associated

results, in the following format:

the original number is 1023

the number reversed 3 2 0 1

the even digits are 0 2

the odd digits are 1 3

-----------------

the original number is 102030

the number reversed 0 3 0 2 0 1

the even digits are 0 2 0 0

the odd digits are 1 3

-----------------

Explanation / Answer

mport java.util.Scanner;

class Sample
{
public static void main(String args[])
{
int n, reverse = 0;
int rev[10];
int i=0;


System.out.println("Enter the number to reverse");
Scanner in = new Scanner(System.in);
n = in.nextInt();

while( n != 0 )
{
reverse = reverse * 10;
reverse = reverse + n%10;
n = n/10;
rev[i] = reverse;
}
for(i=i-1;i>=0;i--)
{
System.out.println(" "+rev[]);
  
System.out.println("the reverse number is "+rev[i]);

if ( rev[i] % 2 == 0 )
System.out.println("even digits are"+rev[i]);
else
System.out.println("odd digits are."+rev[i]);
}
}
}
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote