Write an application that prompts a user for two integers and displays every integer between them. Display There are no integers between X and Y if there are no integers between the entered values. Make sure the program works regardless of which entered value is larger. This is a java assignment. Pls help
//TestCode.java import java.util.Scanner; public class TestCode { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int X, Y; X = scanner.nextInt()+1; Y = scanner.nextInt()-1; if(X<=Y) { for (int i = X; i <= Y; i++) { System.out.print(i+" "); } System.out.println(); } else{ System.out.println("There are no integers between "+(X-1)+" and "+(Y+1)); } } }
Get Answers For Free
Most questions answered within 1 hours.