第四周作业
import java.util.Scanner;
public class DaiMa {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("输入年份");
Scanner input=new Scanner(System.in);
int year=input.nextInt();
System.out.println("输入月份");
int m=input.nextInt();
if(year%4==0&&year%100!=0&&m==2||year%400==0){
System.out.println("29天");
}else{
switch(m){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
System.out.println("31天");
break;
case 2:
System.out.println("28天");
break;
case 4:
case 6:
case 9:
case 11:
System.out.println("30天");
break;
default:
System.out.println("输入错误");
break;
}
}
}
}
mport java.util.Scanner;
public class DaiMa {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("输入年份");
Scanner input=new Scanner(System.in);
int year=input.nextInt();
if(year%4==0&&year%100!=0||year%400==0){
System.out.println("是闰年");
}else{
System.out.println("不是闰年");
}
}
}
public class DaiMa {
/**
* @param args
*/
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("输入分数");
int a=input.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;
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
System.out.println("等级为D");
break;
default:
System.out.println("输入错误");
break;
}
}
}
import java.util.Scanner;
public class DaiMa {
/**
* @param args
*/
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
Random r=new Random();
System.out.println("输入4位会员卡号");
int a=input.nextInt();
int b=r.nextInt(10);
System.out.println("幸运卡号为"+b);
int bai=a/100%10;
if(bai==b){
System.out.println("幸运会员");
}
else{
System.out.println("不是幸运会员");
}
}
}
public class DaiMa {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("输入一个数");
Scanner input=new Scanner(System.in);
int a=input.nextInt();
if(a%2==0){
System.out.println("为偶数");
}
else{
System.out.println("为奇数");
}
}
}
public class DaiMa {
/**
* @param args
*/
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
int y;
if(x>0){
y=x+3;
}else if(x==0){
y=0;
}
else{
y=x*2-1;
}
System.out.println("y值为"+y);
}
}
public class DaiMa {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("输入一个数x");
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(x==1){
System.out.println("x=1");
}else if(x==5){
System.out.println("x=5");
}else if(x==10){
System.out.println("x=10");
}else{
System.out.println("x=none");
}
}
}
public class DaiMa {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("输入三个数");
Scanner input=new Scanner(System.in);
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("不构成三角形");
}
}
}
public class DaiMa {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("输入一个数");
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(x%5==0&&x%6==0){
System.out.println("能被5和6整除");
}else if(x%5==0&&x%6!=0){
System.out.println("能被5整除");
}else if(x%5!=0&&x%6==0){
System.out.println("能被6整除");
}else{
if(x%5!=0&&x%6!=0){
System.out.println("不能被5和6整除");
}
}
}
}