+ 3
How to print ASCII value of characters and symbols take input by user in java
6 Réponses
- 1
Scanner scan = new Scanner(System.in);
char ch = scan.next().charAt(0);
// You can do it like this
int c = ch;
// And you can also cast your char to an int
int cc = (int)ch;
System.out.println(c);
System.out.println(cc);
+ 4
Dèépãk Gûptå
I have made the logic try to take input by own as something should be done by you to complete your hw
class CharToASCII
{
public static int CharToASCII(final char character)
{
return (int) character;
}
public static void main(String args[])
{
char a = 'a';
int i = 65;
System.out.println("Char to ASCII : " + a + " ascii is " + CharToASCII(a));
}
}
+ 3
In this program input is already given by you
+ 3
But I want program take input by another users
+ 3
Done
+ 1
My example will take user input and that is what you wanted