设定一个变量代表月份    根据变量值输出该月份代表的季节(春  夏  秋  冬)

解决方案 »

  1.   

    http://wenwen.soso.com/z/q162570069.htm
      

  2.   


    import java.io.*;public class Season {
    static InputStreamReader inreader = new InputStreamReader(System.in); public static BufferedReader breader = new BufferedReader(inreader); public static void main(String args[]) throws Exception {
    System.out.println("输入月份,以换行结束!");
    int month = ReadData.readInt(); switch (month) {
    case 3:
    case 4:
    case 5:
    System.out.println("Month " + month + " is 春季.");
    break; case 6:
    case 7:
    case 8:
    System.out.println("Month " + month + " is 夏季.");
    break; case 9:
    case 10:
    case 11:
    System.out.println("Monthe " + month + " is 秋季.");
    break; case 12:
    case 1:
    case 2:
    System.out.println("Month " + month + " is 冬季.");
    break; default:
    System.out.println("输入非法!");
    }
    }
    }
      

  3.   

    这很简单吧?就一个switch搞定了!
      

  4.   

    这个刚好是我们java老师 gongbingjiang留的  你不会是工程大学的吧~~~  
    import javax.swing.JOptionPane;public class Test { public static void main(String args[]) throws Exception {
    JOptionPane.showMessageDialog(null, "输入月份!");
    String str = JOptionPane.showInputDialog("请输入一个月份!");
    int month = Integer.parseInt(str); switch (month) {
    case 3:
    case 4:
    case 5:
    JOptionPane.showMessageDialog(null, "Month " + month + " is 春季.");
                break; case 6:
    case 7:
    case 8:
    JOptionPane.showMessageDialog(null, "Month " + month + " is 夏季.");
    break; case 9:
    case 10:
    case 11:
    JOptionPane.showMessageDialog(null, "Month " + month + " is 秋季.");
    break; case 12:
    case 1:
    case 2:
    JOptionPane.showMessageDialog(null, "Month " + month + " is 冬季.");
    break; default:
    JOptionPane.showMessageDialog(null, "哥们,一年一共十二个月份!"); }
    }
    }
      

  5.   

    package Lianxi;
    import java.util.Scanner;
    public class MonthDemo {
    public static void main(String[] args) {
    Scanner console=new Scanner (System.in);

    while(true){
    System.out.println("请输月份:");
    int n=console.nextInt();
         jisuan(n);
    }
    }
      public static void jisuan(int n) {
    switch (n) {
    case 3:case 4:case 5:
    System.out.println("春季");
    break;
    case 6:
    case 7: case 8: System.out.println("夏季");
    break;
    case 9:
    case 10: case 11: System.out.println("秋季");
    break;
    case 12:
    case 1: case 2: System.out.println("冬季");
    break;
    default:
    System.out.println("请输入1到12之间的月份 "); }
      }
    }
      

  6.   

    swith太长了
    直接用月份/4来判定吧
      

  7.   

    int k=11;
    String A="春季";
    String B="夏季";
    String C="秋季";
    String D="冬季";
    System.out.println((k>=1&&k<=3)?A:(k>=4&&k<=6)?B:(k>=7&&k<=9)?C:D);
    }
    这个比较简单吧,希望对你有帮助
      

  8.   

    int month=...接收你输入的月份;
    swith(month/3){
      case 1:
        System.out.println("");
      break;
      case 2:
       System.out.println("");
      break;
      case 3:
        System.out.println("");
      break;  case 4:
       System.out.println("");
      break;
      
      default:
      ....}
      

  9.   

    上面都说了。。  用swith..case..很简单的。
      

  10.   

    如果是实时的信息,用Calender类得到当前的月份。
                    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    int month = cal.get(Calendar.MONTH)+1;
    然后用楼上任意一种方法去判断是哪个季节
      

  11.   

    witch  case  才是王道。。
      

  12.   

    围观.观点.一点.switch ,或者if
    我只有这个建议