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);
}
}
弘速云怎么样?弘速云是创建于2021年的品牌,运营该品牌的公司HOSU LIMITED(中文名称弘速科技有限公司)公司成立于2021年国内公司注册于2019年。HOSU LIMITED主要从事出售香港vps、美国VPS、香港独立服务器、香港站群服务器等,目前在售VPS线路有CN2+BGP、CN2 GIA,该公司旗下产品均采用KVM虚拟化架构。可联系商家代安装iso系统,目前推出全场vps新开7折,...
提速啦 成立于2012年,作为互联网老兵我们一直为用户提供 稳定 高速 高质量的产品。成立至今一直深受用户的喜爱 荣获 “2021年赣州安全大赛第三名” “2020创新企业入围奖” 等殊荣。目前我司在美国拥有4.6万G总内存云服务器资源,香港拥有2.2万G总内存云服务器资源,阿里云香港机房拥有8000G总内存云服务器资源,国内多地区拥有1.6万G总内存云服务器资源,绝非1 2台宿主机的小商家可比。...
tmhhost为2021年暑假开启了全场大促销,全部都是高端线路的VPS,速度快有保障。美国洛杉矶CN2 GIA+200G高防、洛杉矶三网CN2 GIA、洛杉矶CERA机房CN2 GIA,日本软银(100M带宽)、香港BGP直连200M带宽、香港三网CN2 GIA、韩国双向CN2。本次活动结束于8月31日。官方网站:https://www.tmhhost.com8折优惠码:TMH-SUMMER日本...
java代码大全为你推荐
旺旺群发阿里旺旺如何群发信息?存储区域网络网络存储技术的SAN(存储区域网络)的优点网络安全密钥网络安全密钥一般是什么sms是什么什么是SMS协议erp系统教程在一个公司里怎样去学ERP多看论坛kindle哪个型号最好用怎么查微信注册时间微信号用了多久,怎么知道在线沟通有效沟通的六个要点泛微协同办公系统泛微OA系统怎么创建新人员flash序列号Flash软件 的序列号是什么?
buyvm 512av 42u机柜尺寸 建站代码 谁的qq空间最好看 qq对话框 电信主机 如何注册阿里云邮箱 中国电信宽带测速器 linode支付宝 dnspod lamp怎么读 国外网页代理 测试网速命令 apnic 阿里云个人邮箱 googlevoice 标准机柜 西部主机 阿里云宕机故障 更多