1、
import javax.swing.JOptionPane;
public class huahua {
public static void main(String[] args) {
String g = JOptionPane.showInputDialog(null, "请输入三位数");
int a = Integer.parseInt(g);
int b = a / 100;
int c = (a - b * 100) / 10;
// (a-b*100)/10 也可以用a/10%10
int d = (a % 10);
System.out.println(c);
if ((b * b * b) + (c * c * c) + (d * d * d) ==a) {
JOptionPane.showMessageDialog(null, "您输的数字是属于水仙花数");
}else if((b * b * b) + (c * c * c) + (d * d * d) !=a){
JOptionPane.showMessageDialog(null, "抱歉,您输入的不属于水仙花数");
}
}
2、import javax.swing.JOptionPane;
public class work {
public static void main(String[] args) {
String s= JOptionPane.showInputDialog(null,"请输入一个五位数");
int t =Integer.parseInt(s);
int a=t/10000;
int b=t/1000%10;
int c=t/100%10;
int d=t/10%10;
int e= t%10;
if (a==e&&b==d){
JOptionPane.showMessageDialog(null, "您输入的数字是回数");
}
else{
JOptionPane.showMessageDialog(null,"您输入的数字不是回数");
}
}
3、
import javax.swing.JOptionPane;
public class cc {
public static void main(String[] args) {
String a = JOptionPane.showInputDialog(null, "请输入成绩查看优良中差");
int x = Integer.parseInt(a);
if (x < 60) {
JOptionPane.showMessageDialog(null, x + "是不及格的哦!");
}
else if (x >= 60 && x < 80) {
JOptionPane.showMessageDialog(null, x + "是及格的哦");
}
else if (x >= 80 && x < 90) {
JOptionPane.showMessageDialog(null, x + "是良好的哦");
}
//
else {
JOptionPane.showMessageDialog(null, x + "是优秀的哦");
/*
也可以在if前面加上else. 多个if就是多条语句,每个都要判断,
而if else 只要其中一个满足后,后面的else则忽略。*/
}
}
}