代码:
文件名为 process.java
具体代码为:
import java.util.Scanner;
public class process {
public static void main(String[] args)
{
int a=10;
int b=20;
// if else if else 语句
if(a==b)
{
System.out.println("a==b");
}
else if(a>b)
{
System.out.println("a>B");
}
else
{
System.out.println("a<b");
}
// switch语句
Scanner sc=new Scanner(System.in);
System.out.print("请输入今天星期几:");
int week=sc.nextInt();
switch(week)
{
case 1:System.out.println("星期一");
break;
case 2:System.out.println("星期二");
break;
case 3:System.out.println("星期三");
break;
case 4:System.out.println("星期四");
break;
case 5:System.out.println("星期五");
break;
case 6:System.out.println("星期六");
break;
case 7:System.out.println("星期日");
break;
default:System.out.println("输入有误");
}
// 循环语句
// 1.for循环
for(int i=0;i<5;i++)
{
System.out.println("hello world");
}
// 2.while循环
int j=0;
while(j<=5)
{
System.out.print(j);
j++;
}
// 3.do while 循环
do
{
System.out.print(j);
j--;
}while(j>0);
}
}