﻿/* CST8110 - Introduction to Computer Programming
 * Section: 800
 * Semester: 20W
 * Professor: Piyush Jangam
 * Student ID: 040750891
 * Student Email: ross0272@algonquinlive.com
 * Assignment 2
 */
import java.util.Scanner;
import java.lang.Math;

public class TestMax {
    private int minNum = 1; // Defines the lower limit
    private int maxNum = 5; // Defines the upper limit

    // Prompts the user for input and returns the input
    public int inputNum() {
        Scanner input = new Scanner(System.in);
        System.out.print("Please enter an integer: ");
        return input.nextInt();
    }

    // Outputs the user's number, while staying between minNum and maxNum inclusive
    public void displayNum(int userNum) {
        int finalNum = userNum; // Initialize as the user's number
        finalNum = Math.min(finalNum, maxNum); // Checks value against upper limit
        finalNum = Math.max(finalNum, minNum); // Checks value against lower limit
        System.out.printf("Your number is %d", finalNum);
    }

    // Main method
    public static void main(String[] args) {
        TestMax myTest = new TestMax();
        // Passing the input method's return value as an argument to the display method
        myTest.displayNum(myTest.inputNum());
    }
}