public class test2 {
public static void main(String[] args) {
System.out.println("输入一个数字表示今天的星期数:比如2就是代表星期二,7代表星期天");
Scanner sc =new Scanner(System.in);
int weeknum = sc.nextInt();
System.out.println("输入一个查询数字,查询往前天数的星期数");
int count = sc.nextInt();
if(weeknum-count%7>0){
System.out.println("星期"+weeknum+"往前"+count+"天是星期"+(weeknum-count));
}else{
System.out.println("星期"+weeknum+"往前"+count+"天是星期"+(7-(count%7-weeknum)));
}
}
}
最简单的实现,代码修饰后可以转化成输出中文星期