姓名:周帆
碎碎念:最长的一片日志 哈哈
作业A:控制台打印一个整数
package com.itheima.work_1;
import java.util.Scanner;
public class Work_1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();
System.out.println(a);
}
}
作业B:求两个数的和
package com.itheima.work_1;
import java.util.Scanner;
public class work_2 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("请输入第一个值");
int a = in.nextInt();
System.out.println("请输入第二个值");
int b = in.nextInt();
int c = a+b;
System.out.println(c);
}
}
作业C:判断两个数的大小
package com.itheima.work_1;
import java.util.Scanner;
public class Work_3 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("请输入第一个值");
int a = in.nextInt();
System.out.println("请输入第二个值");
int b = in.nextInt();
if(a==b){
System.out.println("他们相等");
}else{
System.out.println("她们不等");
}
}
}
作业D:求三个数的最大值
package com.itheima.work_1;
import java.util.Scanner;
public class Work_4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("请输入第一个值");
int a = in.nextInt();
System.out.println("请输入第二个值");
int b = in.nextInt();
System.out.println("请输入第三个值");
int c = in.nextInt();
int d = (a>b)?((a>c)?a:c):((b>c)?b:c);
System.out.println("最大值为:"+d);
}
}
请签收~~
|
|