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);
}
}
搬瓦工和Vultr哪个好?搬瓦工和Vultr都是非常火爆的国外VPS,可以说是国内网友买的最多的两家,那么搬瓦工和Vultr哪个好?如果要选择VPS,首先我们要考虑成本、服务器质量以及产品的售后服务。老玩家都知道目前在国内最受欢迎的国外VPS服务商vultr和搬瓦工口碑都很不错。搬瓦工和Vultr哪个稳定?搬瓦工和Vultr哪个速度快?为了回答这些问题,本文从线路、速度、功能、售后等多方面对比这两...
这两天在站长群里看到不少有使用DEDECMS织梦程序的朋友比较着急,因为前两天有看到来自DEDECMS,我们熟悉的织梦程序官方发布的公告,将会在10月25日开始全面商业用途的使用DEDECMS内容管理程序的会采用授权收费模式,如果我们有在个人或者企业商业用途的,需要联系且得到授权才可以使用,否则后面会通过维权的方式。对于这个事情,我们可能有些站长经历过,比如字体、图片的版权。以及有一些国内的CMS...
ProfitServer怎么样?ProfitServer好不好。ProfitServer是一家成立于2003的主机商家,是ITC控股的一个部门,主要经营的产品域名、SSL证书、虚拟主机、VPS和独立服务器,机房有俄罗斯、新加坡、荷兰、美国、保加利亚,VPS采用的是KVM虚拟架构,硬盘采用纯SSD,而且最大的优势是不限制流量,大公司运营,机器比较稳定,数据中心众多。此次ProfitServer正在对...
java代码大全为你推荐
bean是什么意思bean是可数名词还是不可数名词,为什么英文名网站介绍几个好的英语学习网站avc是什么格式手机avc格式怎么剪辑avc是什么格式XVID/MPEG/AVC都是什么意思啊怎么用电脑发短信怎样用电脑给别人的手机发短信?java程序员招聘为什么Java程序员工资都很高selectintooracle有select into临时表的用法吗医院排队系统怎么将排队系统的信息显示在led上防火墙技术应用在网络支付流程中,防火墙技术与数据加密技术应用则重点有什么不同?yui3yui 3 月9日 出的专辑的情报
域名批量查询 韩国vps technetcal 12306抢票攻略 好看的桌面背景图 域名转向 双拼域名 申请个人网站 165邮箱 秒杀预告 免费防火墙 www789 美国凤凰城 购买空间 七牛云存储 netvigator 开心online 免费获得q币 学生机 碳云 更多