1.
public class Demo{
public static void main(String[] args){
int a =3;
if(a>0){
System.out.println("你输入的是正数");
}
}
}
2.
public class Demo{
public static void main(String[] args){
int a =3;
if(a>0){
System.out.println("你输入的是正数");
}else if(a<0){
System.out.println("你输入的是负数");
}
}
}
3.
public class Demo{
public static void main(String[] args){
int a =3;
if(a>0){
System.out.println("你输入的是正数");
}else if(a<0){
System.out.println("你输入的是负数");
}else{
System.out.println("你输入的是0");
}
}
}
4.
import java.util.Scanner;
public class Demo{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("请输入你的身高cm:");
int a=input.nextInt();
System.out.println("请输入你的财产:");
int b=input.nextInt();
System.out.println("请输入你是否长的帅:\n帅为true;不帅为false");
boolean c=input.nextBoolean();
if(a > 180 && b > 1000 && c==true){
System.out.println("我一定要嫁给他!!!");
}else if(a > 180 || b > 1000 || c!=false){
System.out.println("嫁吧,比上不足比下有余");
}else{
System.out.println("不嫁!");
}
}
}
5.输出不出来
6.
只能作用在byte,char,int,short上;不能作用的long和String上。
public class Demo{
public static void main(String[] args){
int a =3;
if(a>0){
System.out.println("你输入的是正数");
}
}
}
2.
public class Demo{
public static void main(String[] args){
int a =3;
if(a>0){
System.out.println("你输入的是正数");
}else if(a<0){
System.out.println("你输入的是负数");
}
}
}
3.
public class Demo{
public static void main(String[] args){
int a =3;
if(a>0){
System.out.println("你输入的是正数");
}else if(a<0){
System.out.println("你输入的是负数");
}else{
System.out.println("你输入的是0");
}
}
}
4.
import java.util.Scanner;
public class Demo{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("请输入你的身高cm:");
int a=input.nextInt();
System.out.println("请输入你的财产:");
int b=input.nextInt();
System.out.println("请输入你是否长的帅:\n帅为true;不帅为false");
boolean c=input.nextBoolean();
if(a > 180 && b > 1000 && c==true){
System.out.println("我一定要嫁给他!!!");
}else if(a > 180 || b > 1000 || c!=false){
System.out.println("嫁吧,比上不足比下有余");
}else{
System.out.println("不嫁!");
}
}
}
5.输出不出来
6.
只能作用在byte,char,int,short上;不能作用的long和String上。