Answer the question
In order to leave comments, you need to log in
I'm trying to list the elements in the condition, how?
Hello, I'm just learning Java. And now I ran into a problem, the program reads a number in the hexadecimal number system from the keyboard, and if the user "accidentally" enters a letter that is not part of the hexadecimal number system, write to him that he made a mistake. So far my code is this:
import java.util.*;
public class 987 {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
System.out.print("Введи гексо число: ");
String cislo = sc.next();
cislo = cislo.toUpperCase();
char[] kontrola = cislo.toCharArray();
for(int i = 0; i<kontrola.length; i++){
if(kontrola[i] == 'G'){
kontrola[i] = '.';
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question