java代码大全求个JAVA输入输出完整代码

java代码大全  时间:2021-06-25  阅读:()

求一个简单的java代码

代码如下,每句都加了注释了,希望能帮到你.... import java.util.Scanner; public class Test { public static void main(String[] args) { String name;//保存姓名 int age;//保存年龄 Scanner in = new Scanner(System.in);//用于获取用户的输入 System.out.print("请输入您的姓名 :");//提示用户输入姓名 name = in.nextLine();//提取用户输入的姓名 System.out.print("请输入您的年龄 :");//提示用户输入年龄 age = in.nextInt();//提取用户输入的年龄 System.out.println("姓名 :" + name);//显示用户的姓名 System.out.println("年龄 : " + age);//显示用户的年龄 } }

java语言代码完整的代码

.shijie.test; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class test1 { static mproduct m1 = new mproduct(); static mproduct m2 = new mproduct(); static mproduct m3 = new mproduct(); public static void main(String[] args) { // 初始话数据 GetList(); System.out.println("***************"); System.out.println("请选择购买的商品编号"); System.out.println(m1.id + "." + m1.name + " " + m2.id + "." + m2.name + " " + m2.id + "." + m2.name + " "); System.out.println("***************"); System.out.println("请输入商品编号:"); Scanner s = new Scanner(System.in); int int1 = s.nextInt(); if (int1 == 1) { System.out.println(m1.name + " " + m1.price); } else if (int1 == 2) { System.out.println(m2.name + " " + m2.price); } else if (int1 == 3) { System.out.println(m3.name + " " + m3.price); } System.out.println("是否继续:"); while (new Scanner(System.in).next().equals("y")) { System.out.println("请输入商品编号:"); Scanner s2 = new Scanner(System.in); int int2 = s.nextInt(); if (int1 == 1) { System.out.println(m1.name + " " + m1.price); } else if (int2 == 2) { System.out.println(m2.name + " " + m2.price); } else if (int2 == 3) { System.out.println(m3.name + " " + m3.price); } System.out.println("是否继续:"); } } static class mproduct { int id; String name; double price; } static void GetList() { m1.id = 1; m1.name = "T血"; m1.price = 245.0; m2.id = 2; m2.name = "网球鞋"; m2.price = 570.0; m3.id = 1; m3.name = "网球拍"; m3.price = 247.0; } }

求一个java代码

运行过了,效果绝对让你满意!呵呵…… 说明: 要在E:目录下放置好“头像6.jpg”和“头像5.jpg”作为回答正确、回答错误时候要显示的图片。

(当然啦,你放在项目的根目录下都可以,只要稍微改一下那个路径就可以了) import java.awt.BorderLayout; import javax.swing.JPanel; import javax.swing.JFrame; import java.awt.Dimension; import javax.swing.JLabel; import java.awt.Rectangle; import javax.swing.JRadioButton; import javax.swing.ImageIcon; import javax.swing.*; public class EGshiti extends JFrame { private static final long serialVersionUID = 1L; private JPanel jContentPane = null; private JLabel jLabel = null; private JLabel jLabel1 = null; private JRadioButton jRadioButton = null; private JRadioButton jRadioButton1 = null; private JRadioButton jRadioButton2 = null; private JLabel jLabel2 = null; private JLabel jLabel3 = null; private ButtonGroup bg=null; /** * This is the default constructor */ public EGshiti() { super(); initialize(); } /** * This method initializes this * * @return void */ private void initialize() { this.setSize(336, 291); this.setContentPane(getJContentPane()); this.setTitle("英语试题"); this.setVisible(true); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jLabel3 = new JLabel(); jLabel3.setBounds(new Rectangle(135, 67, 85, 74)); jLabel3.setText(""); jLabel2 = new JLabel(); jLabel2.setBounds(new Rectangle(20, 155, 256, 18)); jLabel1 = new JLabel(); jLabel1.setBounds(new Rectangle(15, 36, 155, 18)); jLabel1.setText("( ) some flowers for you"); jLabel = new JLabel(); jLabel.setBounds(new Rectangle(15, 14, 39, 18)); jLabel.setText("题目:"); jContentPane = new JPanel(); jContentPane.setLayout(null); jContentPane.add(jLabel, null); jContentPane.add(jLabel1, null); jContentPane.add(getJRadioButton(), null); jContentPane.add(getJRadioButton1(), null); jContentPane.add(getJRadioButton2(), null); jContentPane.add(jLabel2, null); jContentPane.add(jLabel3, null); bg=new ButtonGroup(); bg.add(jRadioButton); bg.add(jRadioButton1); bg.add(jRadioButton2); } return jContentPane; } /** * This method initializes jRadioButton * * @return javax.swing.JRadioButton */ private JRadioButton getJRadioButton() { if (jRadioButton == null) { jRadioButton = new JRadioButton(); jRadioButton.setBounds(new Rectangle(16, 60, 88, 26)); jRadioButton.setText("A.给你的花"); jRadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { jLabel3.setIcon(new ImageIcon("E:\头像6.jpg")); jLabel2.setText("正确答案:A。

原因不用解释了吧~~呵呵……"); } }); } return jRadioButton; } /** * This method initializes jRadioButton1 * * @return javax.swing.JRadioButton */ private JRadioButton getJRadioButton1() { if (jRadioButton1 == null) { jRadioButton1 = new JRadioButton(); jRadioButton1.setBounds(new Rectangle(16, 90, 88, 26)); jRadioButton1.setText("B.给他的花"); jRadioButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { jLabel3.setIcon(new ImageIcon("E:\头像5.jpg")); jLabel2.setText("正确答案:A。

原因不用解释了吧~~呵呵……"); } }); } return jRadioButton1; } /** * This method initializes jRadioButton2 * * @return javax.swing.JRadioButton */ private JRadioButton getJRadioButton2() { if (jRadioButton2 == null) { jRadioButton2 = new JRadioButton(); jRadioButton2.setBounds(new Rectangle(16, 123, 88, 26)); jRadioButton2.setText("C.给她的花"); jRadioButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { jLabel3.setIcon(new ImageIcon("E:\头像5.jpg")); jLabel2.setText("正确答案:A。

原因不用解释了吧~~呵呵……"); } }); } return jRadioButton2; } public static void main(String args[]){ new EGshiti(); } } // @jve:decl-index=0:visual-constraint="10,10"

求个JAVA输入输出完整代码

//package ??; import java.util.Scanner; public class D{ public static void main(String args[]) { Scanner input = new Scanner(System.in); double d = input.nextDouble(); System.out.println(d); } }

Vinahost - 越南VPS主机商月6美元 季付以上赠送时长最多半年

Vinahost,这个主机商还是第一次介绍到,翻看商家的介绍信息,是一家成立于2008年的老牌越南主机商,业务涵盖网站设计、域名、SSL证书、电子邮箱、虚拟主机、越南VPS、云计算、越南服务器出租以及设备托管等,机房主要在越南胡志明市的Viettle和VNPT数据中心,其中VNPT数据中心对于国内是三网直连,速度优。类似很多海外主机商一样,希望拓展自己的业务,必须要降价优惠或者增加机房迎合需求用户...

半月湾($59.99/年),升级带宽至200M起步 三网CN2 GIA线路

在前面的文章中就有介绍到半月湾Half Moon Bay Cloud服务商有提供洛杉矶DC5数据中心云服务器,这个堪比我们可能熟悉的某服务商,如果我们有用过的话会发现这个服务商的价格比较贵,而且一直缺货。这里,于是半月湾服务商看到机会来了,于是有新增同机房的CN2 GIA优化线路。在之前的文章中介绍到Half Moon Bay Cloud DC5机房且进行过测评。这次的变化是从原来基础的年付49....

TMTHosting:夏季优惠,美国西雅图VPS月付7折,年付65折,美国服务器95折AS4837线路

tmthosting怎么样?tmthosting家本站也分享过多次,之前也是不温不火的商家,加上商家的价格略贵,之到斯巴达商家出现,这个商家才被中国用户熟知,原因就是斯巴达家的机器是三网回程AS4837线路,而且也没有多余的加价,斯巴达家断货后,有朋友发现TMTHosting竟然也在同一机房,所以大家就都入手了TMTHosting家的机器。目前,TMTHosting商家放出了夏季优惠,针对VPS推...

java代码大全为你推荐
excel大写金额怎么用Excel将小写金额转换成人民币的大写金额国家法规数据库哪个常用的法律APP比较好用?shoujiao手机板aoblox怎么从英文变成中文flash序列号急求flash序列号backupexecBackup Exec 2014怎么备份Exchangeaviconverter哪款AVI转换器好用?推荐一下aviconverter介绍一个好用的免费的avi转换器如何查看qq特别关心我的人怎么在QQ里查看自己有没有被设为特别关心?如何查看qq特别关心我的人手机qq怎么看有多少个人把自己设置为特别关心怎么保存整个网页怎样完整的保存一个网页
怎样注册域名 老域名全部失效请记好新域名 hkbn 息壤备案 42u机柜尺寸 网站监控 服务器日志分析 web服务器架设软件 网通代理服务器 40g硬盘 帽子云 阿里校园 河南移动网 免费dns解析 idc查询 香港亚马逊 网页加速 卡巴斯基官网下载 tracker服务器 hosting24 更多