Write a java Program that display ASCII code of entered Character by user.
Program
import java.util.Scanner; // this package util and Class Scanner is declared to take input from user
/*
*@ scanner class
* @author khant vyas
*/
public class asciicode //asciicode is name of class
{
public static void main(String args[])
{
int x; // x is variable which stores value entered by user
Scanner sc= new Scanner(System.in);// sc is object to the Scanner class
System.out.println("Enter value you wan to see in ascii");
x=sc.nextInt();// nextInt() method is used accept intiger value from user
char c= (char) x ; // this conver character to ascii
System.out.println("ASCII code is "+c);
}
}
Output:-
Program
import java.util.Scanner; // this package util and Class Scanner is declared to take input from user
/*
*@ scanner class
* @author khant vyas
*/
public class asciicode //asciicode is name of class
{
public static void main(String args[])
{
int x; // x is variable which stores value entered by user
Scanner sc= new Scanner(System.in);// sc is object to the Scanner class
System.out.println("Enter value you wan to see in ascii");
x=sc.nextInt();// nextInt() method is used accept intiger value from user
char c= (char) x ; // this conver character to ascii
System.out.println("ASCII code is "+c);
}
}
Output:-
Java Output |
No comments:
Post a Comment