I see some errors in your code.
Your probably meant the mathematical term

90 <= angle <= 180, meaning angle in range 90-180.

if (angle >= 90 && angle <= 180) {

// do action
}
Answer from AlexWien on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java numbers › how to check whether an integer exists in a range with java
How to Check Whether an Integer Exists in a Range with Java | Baeldung
January 17, 2024 - As with ValueRange‘s of() method, we passed lowerBound and upperBound to Range‘s static between() method to create Range objects. We then used the contains() method to check whether number existed within each object’s range.
🌐
Alvin Alexander
alvinalexander.com › java › java-method-integer-is-between-a-range
A Java method to determine if an integer is between a range | alvinalexander.com
If you want, you can make that code shorter with the Java ternary operator syntax (which I don’t like), or better yet, like this:
Top answer
1 of 3
6
public class Method1 {

Since this will be the name of the file too, (if you save it) I would recommend naming it something descriptive so that you don't have to open it in order to know what it hides.


public static float a, b, t;
public static Scanner scanner;

Try and declare as close to the use of the variables as possible. There is also no need for these to be globals, since they are only used in one place.

Next, read the question very carefully. It states that A and B are both integers, so a float is the wrong type to use. It may also give rounding errors, and comparing floats is trickier because of how floating point numbers are stored. 0.1 + 0.1 does not always equal 0.2, it may give 0.200000001, so this can lead to a bug.

Lastly, t is also going to be an integer. You can tell this is the case because it is a count of how many test cases there are, 2.3 testcases doesn't make sense.


HINT TOWARDS AN ERROR

System.out.println("Type your first Value please.");

Why is this here? Does the question ask for it in the output?


Now onto the code overview. Strictly speaking, your code doesn't work at all. You never actually took in all the input. If its input looks like

3
10 20
20 10
10 10

You scan 3, and 10. That is it. All the rest of the input is ignored. There is a reason it tells you how many test cases there will be, its important to use that information.


if (a == b) {
    System.out.println('=');
}
if (a > b){
    System.out.println('>');
}
if (a < b){
    System.out.println("<");
}

This is the perfect time for if/else statements.

One good piece of logic here is if they aren't equal, and a isn't bigger than b, we know the answer to a < b without needing to check.

There are more things to mention, like moving the check if two numbers are equal to a method, and making use of the library of methods available, but get it working first, then post a follow up. Best of luck

2 of 3
3

Don't name anything Method1. It's never going to be a good name but in particular here you used it as the name of a class, which is extra confusing.

You should name a class after its use. Maybe something like OperatorChecker. A name should tell you what the class does, that makes it easier to understand when and how to use it.

🌐
w3resource
w3resource.com › java-exercises › basic › java-basic-exercise-64.php
Java - Test if 2 numbers have the same digit between 2 values
import java.util.*; public class ... b = in.nextInt(); // Read and store the second number // Call the common_digit method with the two numbers and print the result System.out.println("Result: " + common_digit(a, b)); } ...
🌐
Behind Java
behindjava.com › between-two-numbers-with-java
How to Check if a variable is between two numbers with Java - Behind Java
Finally, validate the range by returning from = toCheck && toCheck = to; using the public static boolean isBetween(int toCheck, int from, int to) function. Importing static Math.isBetween allows you to write code like this, which is the first ...
Find elsewhere
🌐
Medium
medium.com › @AlexanderObregon › checking-if-a-number-is-within-a-range-in-java-da2729ea3e05
Checking if a Number Is Within a Range in Java | Medium
August 25, 2025 - Learn how Java checks if numbers fall within a range. Covers comparison operators, inclusive and exclusive limits, floating point rules, and edge cases.
🌐
javathinking
javathinking.com › blog › check-if-a-variable-is-between-two-numbers-with-java
Java: How to Check if a Variable is Between Two Numbers – Fixing 'Left-Hand Side of Assignment Must Be a Variable' Error
Java requires explicit comparison of each bound using the logical AND operator (&&). This ensures both conditions are evaluated: ... int x = 7; int lower = 5; int upper = 10; // ✅ Correct: Check if x is between 5 (exclusive) and 10 (exclusive) ...
🌐
Educative
educative.io › answers › what-is-rangebetween-in-java
What is Range.between() in Java?
between() is a staticthe methods in Java that can be called without creating an object of the class. method of the Range which is used to obtain an instance of Range with the specified minimum and maximum value.
🌐
GeeksforGeeks
geeksforgeeks.org › java › check-if-two-integers-are-equal-or-not-in-java
Check if Two Integers are Equal or Not in Java - GeeksforGeeks
June 21, 2021 - If two numbers are equal then their subtraction is equal to 0. ... // Check Two Integers are Equal or Not in Java // using arithmetic operator import java.io.*; class GFG { public static void main(String[] args) { int firstNumber = 15; int secondNumber = 15; if ((firstNumber - secondNumber) == 0) System.out.println("Numbers are equal"); else System.out.println("Numbers are not equal"); } }
🌐
LabEx
labex.io › tutorials › java-how-to-check-if-a-number-is-within-a-specific-range-in-java-559970
How to Check If a Number Is Within a Specific Range in Java | LabEx
For example, if our range is [10, 50], a number is considered within the range if it is 10, 50, or any number between 10 and 50. If we had used > (greater than) and < (less than) instead, the range would be (10, 50), which means 10 and 50 themselves would not be included. Let's confirm this behavior by testing our program with the boundary values. Open the HelloJava.java file in the WebIDE editor.
🌐
TutorialsPoint
tutorialspoint.com › check-two-numbers-for-equality-in-java
Check two numbers for equality in Java
To check two numbers for equality in Java, we can use the Equals() method as well as the == operator. Firstly, let us set Integers. Integer val1 = new Integer(5); Integer val2 = new Integer(5); Now,
🌐
Coderanch
coderanch.com › t › 481376 › java › write-statement-range-values
how to write: IF statement with range of values (e.g. if 5 > x > 10, then ... ) (Beginning Java forum at Coderanch)
saddam mohammed wrote:. . . // This is correct range of x between 5 and 10 . . . That is probably not correct; please write which numbers will cause that test to evaluate to true.
🌐
Coderanch
coderanch.com › t › 752546 › java › statements-compare-numbers
Using IF statements to compare two numbers (Beginning Java forum at Coderanch)
I would think you want to print the value of n1 and n2, possibly with some text in between, to do that, you can write something like this: System.out.println("n1 has value " + n1); What i have there is a string literal: "n1 has value ", followed by a variable, the '+' in between means "concatenate ...