package week4; public class Limit { /* * Create an algorithm and code a solution to the following scenario: Write a program that determines whether a user supplied value is inside or outside an interval. For example, the value 6 is inside the interval from 2 to 8, while the value 9 is outside the interval ranging from 1 to 5. Write a program that • Reads the lower and upper limits of an integer interval. • Reads a value • Reports back if the value is inside or outside the given interval Enter the lower limit of interval (integer): 2 Enter the upper limit of interval (integer): 8 The value 6 lies within the interval (2, 8) Input:Get upper limit, lower limit and value from user Process: if (value >= lower limit and value <= upper limit) then output “The value lies within the interval” else output “The value lies outside the interval” Output: Print out if the value is inside or outside the interval * * */ public static void main(String[] args) { // Get the upper limit, lower limit and value from user java.util.Scanner scanner = new java.util.Scanner(System.in); System.out.print("Enter the lower limit of interval (integer): "); int lowerLimit = scanner.nextInt(); System.out.print("Enter the upper limit of interval (integer): "); int upperLimit = scanner.nextInt(); System.out.print("Enter the value: "); int value = scanner.nextInt(); scanner.close(); // Process String message = ""; if (value >= lowerLimit && value <= upperLimit) { message = "The value lies within the interval"; } else { message = "The value lies outside the interval"; } // Output System.out.println(message); } }