+ 3

How to print ASCII value of characters and symbols take input by user in java

28th May 2019, 9:14 AM
Dèépãk Gûptå
Dèépãk Gûptå - avatar
6 ответов
- 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);
28th May 2019, 9:34 AM
JavaBobbo
JavaBobbo - avatar
+ 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)); } }
28th May 2019, 9:33 AM
MsJ
MsJ - avatar
+ 3
In this program input is already given by you
28th May 2019, 9:37 AM
Dèépãk Gûptå
Dèépãk Gûptå - avatar
+ 3
But I want program take input by another users
28th May 2019, 9:39 AM
Dèépãk Gûptå
Dèépãk Gûptå - avatar
+ 3
Done
28th May 2019, 9:48 AM
Dèépãk Gûptå
Dèépãk Gûptå - avatar
+ 1
My example will take user input and that is what you wanted
28th May 2019, 9:44 AM
JavaBobbo
JavaBobbo - avatar