This is an image of the exact error I get
I am new to Java, and I am trying to write a program for converting Hexiacosadecimals to regular decimals and for whatever reason after fixing what I thought was every bug I keep getting unresolved compilation errors, please If anyone can help with the likely minor issue that is screwing with the compilation I would be greatly appreciative.
import java.util.Scanner;
public class HexiacosadecimalNumber {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print(
"Please enter 'h' to convert from hexiacosadecmial to decimal,or 'd' to convert from decimal,or'q'to aquit:");
char convar = input.next().charAt(0);
;
if (convar == 'h' || convar == 'H') {
System.out.print("Please enter your hexiacosadecimal number:");
String hexano = input.nextLine();
} else if (convar == 'd' || convar == 'D') {
System.out.print("Please enter your decimal number:");
double Decno = input.nextDouble();
} else if (convar == 'q' || convar == 'Q') {
System.exit(0);
} else {
System.out.print("INVALID INPUT");
}
}
}
CodePudding user response:
Compilation errors where? code should work the only issue I can see for now is : String hexano = input.nextLine(); If you enter 'h' or 'H' and click Enter. orbably Enter will be automatically read by input.nextLine() and program will end
To avoid that you can get that enter in first line in this if statement using : input.nextLine();
CodePudding user response:
Can you provide an example of a compilation error that you have? While reviewing your code, I noticed you had an extra semicolon. And it's called hexadecimal.
char convar = input.next().charAt(0);
;