import java.util.Scanner; public class StringDome9 { public static void main(String[] args) { //对应罗马数字 //创建输入 boolean judge=false; while(judge==false) { Scanner sc = new Scanner(System.in); String value = sc.next(); judge = Judge(value); if (judge == false) { System.out.println("请输入一个长度小于等于九的正整数"); } else { String str=Zhuan(value); System.out.println(str); break; } } } public static boolean Judge(String value){ if(value.length()>9){ return false; } for (int i = 0; i < value.length(); i++) { if(value.charAt(i)<'0'||value.charAt(i)>'9'){ return false; } } return true; }
Java数字与罗马数字转换
最新推荐文章于 2024-07-25 16:24:05 发布