liang183 发表于 2016-12-24 15:30:39

java编程实现找到将来的日期源码答案

package nameyu;import java.util.Scanner;public class Test {     /**   * @param args   */    public static void main(String[] args) {      // TODO Auto-generated method stub      Scanner input=new Scanner(System.in);      System.out.println("Enter today's day instead of number 0-6: (0:sunday 1:monday...6:saturday)");      int weeks=input.nextInt();      System.out.print("Enter the number of days elapsed since today:");      int days=input.nextInt();      int newdaysweek=(weeks+days)%7;      String output=" ";      switch(newdaysweek){      case 0: output="Sunday";break;      case 1: output="Monday";break;      case 2: output="Tuesday";break;      case 3: output="Wednesday";break;      case 4: output="Thursday";break;      case 5: output="Friday";break;      case 6: output="Saturday";      }      String day=" ";      switch(weeks){      case 0:day="Sunday";break;      case 1: day="Monday";break;      case 2: day="Tuesday";break;      case 3: day="Wednesday";break;      case 4: day="Thursday";break;      case 5: day="Friday";break;      case 6: day="Saturday";      }      System.out.println("Today is "+day+" and the future day is "+output);      }    }   
页: [1]
查看完整版本: java编程实现找到将来的日期源码答案