1个回答
展开全部
非闰年
import java.io.*;
public class Test {
/**
* @param args
*
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String inputStr=null;
String input[]={"1","2","3","4","5","6","7","8","9",
"10","11","12"};
String output[]={"31","28","31","30","31","30",
"31","31","30","31","30","31"};
System.out.print("请输入1-12的整数!");
try {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
while(true){
boolean flag=true;
inputStr=br.readLine();
for(int i=0;i<input.length;i++){
if(inputStr.equals(input[i])){
//有就b标志置false
flag=false;
//跳出循环
break;
}
}
if (!flag)
break;
System.out.print("请重新输入1-12的整数!");
}
for(int j=0;j<input.length;j++){
if(inputStr.equals(input[j]))
System.out.println(input[j]+"月有"+output[j]+"天");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.*;
public class Test {
/**
* @param args
*
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String inputStr=null;
String input[]={"1","2","3","4","5","6","7","8","9",
"10","11","12"};
String output[]={"31","28","31","30","31","30",
"31","31","30","31","30","31"};
System.out.print("请输入1-12的整数!");
try {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
while(true){
boolean flag=true;
inputStr=br.readLine();
for(int i=0;i<input.length;i++){
if(inputStr.equals(input[i])){
//有就b标志置false
flag=false;
//跳出循环
break;
}
}
if (!flag)
break;
System.out.print("请重新输入1-12的整数!");
}
for(int j=0;j<input.length;j++){
if(inputStr.equals(input[j]))
System.out.println(input[j]+"月有"+output[j]+"天");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询