java 从键盘输入一位整数,当输入1-7时,显示下面对应的英文字母星期几的名称
展开全部
package pac;
import java.util.Scanner;
public class FirstJava {
//Sunday, Monday, Tuesday,
//Wednesday, Thursday, Friday, Saturday,
public static String wk[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// display :This is my first program
System.out.println("This is my first program!");
week();
}
public static int week()
{
Scanner sc=new Scanner(System.in);
int i=sc.nextInt();
if(i==0) return 0;
else if(i<0||i>7) week();
else System.out.println(wk[i-1]);
return 1;
}
import java.util.Scanner;
public class FirstJava {
//Sunday, Monday, Tuesday,
//Wednesday, Thursday, Friday, Saturday,
public static String wk[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// display :This is my first program
System.out.println("This is my first program!");
week();
}
public static int week()
{
Scanner sc=new Scanner(System.in);
int i=sc.nextInt();
if(i==0) return 0;
else if(i<0||i>7) week();
else System.out.println(wk[i-1]);
return 1;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询