今天正式开始学习java代码编写

主要做一些随堂代码练习以及个人笔记,

 

 

import javax.swing.JOptionPane;//JOptionPane为系统所提供对话框的类,*加载包内所有内容,加载时间较长。
public class test{
 public static void main (String[] args){
 final double PI=3.141592654;//final 将PI变为常量,无法对其做更改,常量通常所有字母大写。
 JOptionPane.showMessageDialog(null,"do");//显示消息框,位置居中,内容“do”  
 String Name = JOptionPane.showInputDialog(null,"请输入你的姓名");//显示一个输入框,使用一个变量来记录输入的内容。便于其他内容调用该变量。
 JOptionPane.showMessageDialog(null,"welcome,"+Name);
 
 }
}
import javax.swing.JOptionPane;
public class jack{
 public static void main(String[] args){
  String weigh=JOptionPane.showInputDialog(null,"请输入宽");
  String longer=JOptionPane.showInputDialog(null,"请输入长");
  //将字符串转化为整型。
  int W = Integer.parseInt(weigh);//Integer(系统提供的的一种方法)parseInt(Integer系统提供的一种方法)
  int L = Integer.parseInt(longer);
  JOptionPane.showMessageDialog(null,"长方形面积为:"+W*L);

 }
}

import javax.swing.JOptionPane;
public class jack{
 public static void main(String[] args){
  String A = JOptionPane.showInputDialog(null,"请输入第一个数字");
  String B = JOptionPane.showInputDialog(null,"请输入第二个数字");
  int C = Integer.parseInt(A);
  int D = Integer.parseInt(B);
  JOptionPane.showMessageDialog(null,C+"+"+D+"="+(C+D)+"\n"+C+"-"+D+"="+(C-D)+"\n"+C+"*"+D+"="+C*D+"\n"+C+"/"+D+"="+C/D+"\n");
  switch(C){
  case 1:System.out.println("aaa");
   break;
  case 2:System.out.println("bbb");
   break;
  case 3:System.out.println("ccc");
   break;
  case 4:System.out.println("ddd");
   break;
  case 5:System.out.println("eee");
   break;
  default:System.out.println("xxx");
  }
 }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值