输入小写字母,输出此字母之后的第五个大写字母(软通动力2017校招面试题) 如:输入小写的a,输出F

xiaoxiao2021-02-27  226

import java.util.Scanner; public class HomeWork3 { public static void main(String[] args) { /* * 3.输入小写字母,输出此字母之后的第五个大写字母(软通动力2017校招面试题) 如:输入小写的a,输出F */ do { Scanner scanner = new Scanner(System.in); System.out.println("请输入一个小写字母(a~u)"); char c = scanner.next().charAt(0); while (c > 117) { System.out.println("此后第5个没有对应的大写字母,请重新输入:"); c = scanner.next().charAt(0); } String s = String.valueOf((char) (c - 27)); System.out.println(s); System.out.println("是否继续? 1.是 2.否"); int b = scanner.nextInt(); while (b != 1 && b != 2) { System.out.println("请重新输入:"); b = scanner.nextInt(); } if (b == 1) { } else { break; } } while (true); // System.out.println(s.toUpperCase()); }

}

转载请注明原文地址: https://www.6miu.com/read-10827.html

最新回复(0)