第四次作业
import java.util.Scanner;
public class 作 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("输入年份");
int x=input.nextInt();
if (x%4==0&&x%100!=0||x%400==0) {
System.out.println("闰年");
}
else {
System.out.println("不是闰年");
}
}
}
package 作业;
import java.util.Random;
import java.util.Scanner;
public class zuoye2 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
Random r=new Random();
System.out.println("请输入四位数");
int a=input.nextInt();
int b=r.nextInt();
if(a%1000/100==b){
System.out.println("幸运会员");
}else{
System.out.println("非幸运会员");
}
}
}
package 作业;
import java.util.Scanner;
public class zuoye3 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("输入x的值");
int x=input.nextInt();
if (x>0) {
System.out.println("y="+(x+3));
}
else if (x==0) {
System.out.println("y=0");
}
else {
System.out.println("y="+(x*2-1));
}
}
}
package 作业;
import java.util.Scanner;
public class zuoye4 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("请依次输入a,b,c");
int a=input.nextInt();
int b=input.nextInt();
int c=input.nextInt();
if (a+b>c&&a+c>b&&b+c>a) {
System.out.println("可以构成三角形");
}
else {
System.out.println("不能构成三角形");
}
}
}
课下作业
package 课下作业;
import java.util.Scanner;
public class 作业1 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("输入年月");
int year = s.nextInt();
int month = s.nextInt();
int day = 0;
switch(month){
case 1:day=31;break;
case 2:day=28;break;
case 3:day=31;break;
case 4:day=30;break;
case 5:day=31;break;
case 6:day=30;break;
case 7:day=31;break;
case 8:day=31;break;
case 9:day=30;break;
case 10:day=31;break;
case 11:day=30;break;
case 12:day=31;break;
};
if(year%4==0&&year%100==0||year%400==0){
if(month==2){
day=29;
}
}
System.out.println(day);
}
}
package 课下作业;
import java.util.Scanner;
public class zuoye2 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("输入成绩: ");
int a = s.nextInt();
switch(a/10){
case 10:
case 9:
System.out.println("成绩等级:A");
break;
case 8:
System.out.println("成绩等级:B");
break;
case 7:
System.out.println("成绩等级:C");
break;
case 6:
System.out.println("成绩等级:D");
break;
default:
System.out.println("成绩等级:E");
}
}
}
package 课下作业;
import java.util.Scanner;
public class 作业3{
/**
* @param args
*/
public static void main(String[] args) {
Scanner input =new Scanner(System.in);
System.out.println("输入一个数");
int num=input.nextInt();
if(num%2==0){
System.out.println(num+"是偶数");
}else{
System.out.println(num+"是奇数");
}
}
}
package 课下作业;
import java.util.Scanner;
public class 作业4{
/**
* @param args
*/
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("输入一个数");
int x=input.nextInt();
if (x==1||x==5||x==10) {
System.out.println("x="+x);
} else {
System.out.println("x=none");
}
}
}
package 课下作业;
import java.util.Scanner;
public class 作业5 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("输入一个数");
int num = input.nextInt();
if (num % 5 == 0 && num % 6 == 0) {
System.out.println(num + "能被5和6整除");
} else if (num % 5 == 0) {
System.out.println(num + "能被5整除");
} else if (num % 6 == 0) {
System.out.println(num + "能被6整除");
} else if (num % 5 != 0 && num % 6 != 0) {
System.out.println(num + "不能被5或6整除");
}
}
}