Finding the relationship between two values My code was made as an practice for CodeChef. Here's the brief from that page:


  Relational Operators are operators which check the relationship between two values.
  Given two numerical values A and B you need to help chef in finding the relationship between them that is:
  First one is greater than second or
  First one is less than second or
  First and second one are equal.  


I couldn't submit the code because of an error so I'd like to see the criticism of the Code Review community.

package main;

import java.util.Scanner;

public class Method1 {
    public static float a, b, t;
    public static Scanner scanner;

    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        System.out.println("Type your first Value please.");
        a = scanner.nextFloat();
        System.out.println("Type your second Value please.");
        b = scanner.nextFloat();
        if (a == b) {
            System.out.println('=');
        }
       if (a &gt; b){
           System.out.println('&gt;');
       }
       if (a &lt; b){
           System.out.println("&lt;");
       }
    }
}


I would like to note that I know its very basic and easy to make but its just a practice for me to see where I'm at in this kinda stuff.
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 &gt; b){
    System.out.println('&gt;');
}
if (a &lt; b){
    System.out.println("&lt;");
}


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 &lt; 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