JAVA学习初步 星期判断、最小数判断、水仙花数

来源:互联网 发布:淘宝客qq群链接生成 编辑:程序博客网 时间:2024/05/18 13:09
package 判断星期;
import javax.swing.JOptionPane;
public class usageofswitch {

 public static void main(String[] args) {
  // TODO 自动生成的方法存根
  String Number;
  int number;
  Number = JOptionPane.showInputDialog("输入一个1~7之间的整数:");
  number = Integer.parseInt(Number);
  if(number<1||number>7)
   Number = JOptionPane.showInputDialog("输入错误,请重新输入:");
  number = Integer.parseInt(Number);
  switch(number){
  case 1:JOptionPane.showMessageDialog(null,"这一天的英文是Monday","英语表达",JOptionPane.PLAIN_MESSAGE);break;
  case 2:JOptionPane.showMessageDialog(null,"这一天的英文是Tuesday","英语表达",JOptionPane.PLAIN_MESSAGE);break;
  case 3:JOptionPane.showMessageDialog(null,"这一天的英文是Wednesday","英语表达",JOptionPane.PLAIN_MESSAGE);break;
  case 4:JOptionPane.showMessageDialog(null,"这一天的英文是Thursday","英语表达",JOptionPane.PLAIN_MESSAGE);break;
  case 5:JOptionPane.showMessageDialog(null,"这一天的英文是Friday","英语表达",JOptionPane.PLAIN_MESSAGE);break;
  case 6:JOptionPane.showMessageDialog(null,"这一天的英文是Saturday","英语表达",JOptionPane.PLAIN_MESSAGE);break;
  case 7:JOptionPane.showMessageDialog(null,"这一天的英文是Sunday","英语表达",JOptionPane.PLAIN_MESSAGE);break;
  default:JOptionPane.showMessageDialog(null,"error!!!","英语表达",JOptionPane.PLAIN_MESSAGE);
  }
  System.exit(0);
 }
}

package 判断最小数;
import java.awt.event.InputEvent;
import java.util.Scanner;
public class Findmini {

 public static void main(String[] args) {
  // TODO 自动生成的方法存根
  Scanner input = new Scanner(System.in);
  int a,b,c,mini;
  System.out.print("输入第一个数:");
  a = input.nextInt();
  System.out.print("输入第二个数:");
  b = input.nextInt();
  System.out.print("输入第三个数:");
  c = input.nextInt();
  mini=(a<b?a:b)<c?(a<b?a:b):c;
  System.out.print("三个数中的最小数为:"+mini);
 }
}

0 0
原创粉丝点击