Question: 1. Allows user is to repeat/continue the program as many times as he/she wants Please add it to the code below import java.util.Scanner; public class

1. Allows user is to repeat/continue the program as many times as he/she wants Please add it to the code below import java.util.Scanner;

public class FormattingInteger {

//reverse method

public static void reverse (int num) {

int num_reverse=0;

while(num != 0)

{

num_reverse = num_reverse * 10;

num_reverse = num_reverse + num%10;

num = num/10;

}

System.out.println("the number reversed "+num_reverse);

}

//even method

public static void even(int num) {

int even;

System.out.print("the even digits are ");

while(num>0) {

even=num%10;

if(even%2==0) {

System.out.print(even +" ");

}

num=num/10;

}

}

//odd method

public static void odd(int num) {

int odd;

System.out.print("the odd digits are ");

while(num>0) {

odd=num%10;

if(odd%2!=0) {

System.out.print(odd +" ");

}

num=num/10;

}

}

//validate method

public static String validate (int num) {

if(num>0) {

return "Enter number is gratter than zero";

}

else {

return "Enter number is less than zero";

}

}

public static void main(String[] args) {

System.out.println("Enter the number : ");

Scanner sc =new Scanner(System.in);

int num =sc.nextInt();

validate(num);

System.out.println("the original number is : "+num);

reverse(num);

even(num);

System.out.println();

odd(num);

sc.close();

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!