public class Task1 {
public static void main(String[] args){
Scanner a=new Scanner(System.in);
System.out.println("请输入你想要打印的值:");
int b=a.nextInt();
System.out.println("你输入的值为:"+b);
}
}
第二题:
package com.itheima.task;
import java.util.Scanner;
public class Task2 {
public static void main(String[] args){
Scanner a=new Scanner(System.in);
System.out.println("请输入一个加数:");
int b=a.nextInt();
System.out.println("请输入另一个加数:");
int c=a.nextInt();
int d=b+c;
System.out.println("他们的和为:"+d);
}
}
第三题:
package com.itheima.task;
import java.util.Scanner;
public class Task3 {
public static void main(String[] args){
Scanner a=new Scanner(System.in);
System.out.println("请输入一个数:");
int b=a.nextInt();
System.out.println("请输入另一个数:");
int c=a.nextInt();
if(b==c){
System.out.println("他们相等");
}else{
System.out.println("他们不相等");
}
}
}
第四题:
package com.itheima.task;
import java.util.Scanner;
public class Task4 {
public static void main(String[] args) {
Scanner a = new Scanner(System.in);
System.out.println("请输入第一个数:");
int b = a.nextInt();
System.out.println("请输入第二个数:");
int c = a.nextInt();
System.out.println("请输入第三个数:");
int d = a.nextInt();
int e = (b > c) ? ((b > d) ? b : d) : ((c > d) ? c : d);
System.out.println("他们的最大值为:"+e);
}
}