Assignment was to compare two strings that have one letter from the alphabet. the output should be which of them has the greatest value(which letter is closer towards z). for example, if the user entered "a" for the first string and "b" for the second string, the output should say that "a" is less than "b." (a=1, b=2, c=3 and so on until z=26). So far, the user can only enter the two strings, but there is no output and i have no idea why. Can someone give me a pointer?
Thanks in advance!import java.util.Scanner; public class SmallestChar { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String char1, char2; int value1 = 0, value2 = 0; System.out.println("Enter first char: "); char1 = scan.next(); System.out.println("Enter second char: "); char2 = scan.next(); if(char1 == "a") value1 = 1; else if(char1 == "b") value1 = 2; else if(char1 == "c") value1 = 3; else if(char1 == "d") value1 = 4; else if(char1 == "e") value1 = 5; else if(char1 == "f") value1 = 6; else if(char1 == "g") value1 = 7; else if(char1 == "h") value1 = 8; else if(char1 == "i") value1 = 9; else if(char1 == "j") value1 = 10; else if(char1 == "k") value1 = 11; else if(char1 == "l") value1 = 12; else if(char1 == "m") value1 = 13; else if(char1 == "n") value1 = 14; else if(char1 == "o") value1 = 15; else if(char1 == "p") value1 = 16; else if(char1 == "q") value1 = 17; else if(char1 == "r") value1 = 18; else if(char1 == "s") value1 = 19; else if(char1 == "t") value1 = 20; else if(char1 == "u") value1 = 21; else if(char1 == "v") value1 = 22; else if(char1 == "w") value1 = 23; else if(char1 == "x") value1 = 24; else if(char1 == "y") value1 = 25; else if(char1 == "z") value1 = 26; if(char2 == "a") value2 = 1; else if(char2 == "b") value2 = 2; else if(char2 == "c") value2 = 3; else if(char2 == "d") value2 = 4; else if(char2 == "e") value2 = 5; else if(char2 == "f") value2 = 6; else if(char2 == "g") value2 = 7; else if(char2 == "h") value2 = 8; else if(char2 == "i") value2 = 9; else if(char2 == "j") value2 = 10; else if(char2 == "k") value2 = 11; else if(char2 == "l") value2 = 12; else if(char2 == "m") value2 = 13; else if(char2 == "n") value2 = 14; else if(char2 == "o") value2 = 15; else if(char2 == "p") value2 = 16; else if(char2 == "q") value2 = 17; else if(char2 == "r") value2 = 18; else if(char2 == "s") value2 = 19; else if(char2 == "t") value2 = 20; else if(char2 == "u") value2 = 21; else if(char2 == "v") value2 = 22; else if(char2 == "w") value2 = 23; else if(char2 == "x") value2 = 24; else if(char2 == "y") value2 = 25; else if(char2 == "z") value2 = 26; if (value1 > value2) System.out.println("The smaller value of " + char1 + " and " + char2 + " is " + char2 + "."); if(value1 < value2) System.out.println("The smaller value of " + char1 + " and " + char2 + " is " + char1 + "."); if(char1 == char2) System.out.println("The values are both \'" + char1 + "\'."); } }