See someone ask the program, went to write a few lines of code, by the way review the conditional statement and ASCII code
1 ImportJava.util.Scanner;2 Public classTest1 {3 4 Public Static voidMain (string[] args)5 {6Scanner sc =NewScanner (system.in);7System.out.print ("Enter an ASCII value:");8 intASCII =sc.nextint ();9 sc.close ();Ten CharCH = (Char) ASCII; One //Turn ' a ' ~ ' z ' to ' a ' ~ ' Z ' A if(Ch >= ' a ' && ch <= ' Z ') - { -System.out.println ((Char) (ch-32)); the } - //Turn ' a ' ~ ' z ' to ' a ' ~ ' Z ' - Else if(Ch >= ' A ' && ch <= ' Z ') - { +System.out.println ((Char) (ch+32)); - } + //output 0~9 in ' 0 ' ~ ' 9 ' A Else if(Ch >= ' 0 ' && ch <= ' 9 ') at { - System.out.println (CH); - } - //Output "+-*/" - Else if(ch = = ' + ' | | ch== '-' | | ch = = ' * ' | | ch = = '/')) - { inSystem.out.println ("belongs to arithmetic operator"); - } to //output "illegal characters" + Else - { theSYSTEM.OUT.PRINTLN ("illegal character"); * } $ }Panax Notoginseng}
Conv New, published in the blog Park
Reprint please indicate the source, welcome mail exchange:[email protected]
Data conversion of small Java experiments