「java怎么循环大写字母」java大小写字母
本篇文章给大家谈谈java怎么循环大写字母,以及java大小写字母对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
java应用程序输出全部大小写字母用for循环?
* @Author jinliwei
* @Date 2019/9/20 14:02
**/
public class A {
public static void main(String[] args) {
int width=25;
int height=width/2;
for (int i=0;iheight;i++){
for (int j=0;jwidth;j++){
if (i==((height+1)/2)){
if (j=width/2-i j=width/2+i){
// if (j%3==0){
// System.out.print("*");
// }else {
// System.out.print(" ");
// }
System.out.print("*");
}else {
System.out.print(" ");
}
}else {
if (j == width/2+i){
System.out.print("*");
} else if (j == width/2-i){
System.out.print("*");
} else {
System.out.print(" ");
}
}
}
System.out.println(" ");
}
}
}
Java编写一个函数用于只能输入大写字母(可循环、可递归实现),并返回该字母。
大致代码如下:
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个大写字母:");
String str = sc.nextLine();
System.out.println("你输入的是"+str);
if ((str.charAt(0) = 'Z' str.charAt(0) = 'A')) {
switch (str.charAt(0)) {
case 'M':
System.out.println("星期一: Mon.=Monday");break;
case 'W':
System.out.println("星期三: Wed.=Wednesday");break;
case 'T':
System.out.println("请再输入一个大写字母:");
String t = sc.nextLine();
System.out.println("你输入的是"+t);
if ((t.charAt(0) = 'Z' t.charAt(0) = 'A')) {
if (t.charAt(0) == 'U') {
System.out.println("星期二: Tues.=Tuesday");break;
} else if (t.charAt(0) == 'H') {
System.out.println("星期四: Thur.=Thursday");break;
} else {
System.out.println("输入错误!");break;
}
}
case 'F':
System.out.println("星期五: Fri.=Friday");break;
case 'S':
System.out.println("请再输入一个大写字母:");
String s = sc.nextLine();
System.out.println("你输入的是"+s);
if ((s.charAt(0) = 'Z' s.charAt(0) = 'A')) {
if (s.charAt(0) == 'A') {
System.out.println("星期六: Sat.=Saturday");break;
} else if (s.charAt(0) == 'U') {
System.out.println("星期天: Sun.=Sunday");break;
} else {
System.out.println("输入错误!");break;
}
}
}
//Default:
// System.out.println("不好意思!星期没有以"+str+"开头的!");
} else {
System.out.println("这都能错?无药可救了!");
}
}
}
在JAVA语言中如何让大写字符进行循环
给点提示吧,JAVA中字符是可以当数值来直接+的,所以你直接让A不停往上+就可以了
关于java怎么循环大写字母和java大小写字母的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
发布于:2022-11-22,除非注明,否则均为
原创文章,转载请注明出处。