⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ifelseifexample.java

📁 it is a good tool to help you study java
💻 JAVA
字号:
//This programe demonsteates if_else_if statement
class IfElseIfExample
    {
   public static void main(String args[]) throws java.io.IOException
{
int month=4;
String season;
System.out.println("Please enter the month:");
//month=(char)System.in.read();
if(month==12||month==1||month==2)
season="winter";
else if(month==3||month==4||month==5)
season="spring";
else if(month==6||month==7||month==8)
season="summer";
else if(month==9||month==10||month==11)
season="auturn";
else
season="Bongus month";
System.out.println("The month you enter is in the "+season+".");
} 
    }
//java中的键盘输入字符通过System.in.read()来读入,这是一个java的控制台输入函数.尽管java的中断//I/O(输入输出)方法在后续章节中将介绍,在这里用System.in.read()读入用户的选择,它从标准的输入读取字//符,因此要将month定义为字符型.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -