4.3-4-2a 输出对应字母的ASCII值

来源:互联网 发布:淘宝流量充值如何退款 编辑:程序博客网 时间:2024/06/15 10:56

题目描述

从键盘上输入一个字母,编写程序,输出与之对应的ASCII编码值。

输入

输入一个字母

输出

输出对应的ASCII编码值,提示信息格式如下:
The ASCII of ‘字符’ is 对应的ASCII编码值.

样例输入1:

c

样例输出1:

The ASCII of ‘c’ is 99.

样例输入2:

B

样例输出2:

The ASCII of ‘B’ is 66.

import java.util.Scanner;public class Main {    public static void main(String[] args) {        // TODO 自动生成的方法存根        Scanner in=new Scanner(System.in);        String temp=null;        int change_result=0;        temp=in.nextLine();        char []chars=temp.toCharArray();        change_result=chars[0];        System.out.print("The ASCII of "+"'"+chars[0]+"'"+" is "+change_result+".");    }}
0 0