当前位置:首页 » 编程语言 » java程序设计基础篇答案

java程序设计基础篇答案

发布时间: 2022-10-30 08:07:33

1. 《java语言程序设计基础篇》机械工程出版社 课后习题答案

你也知道这本书在官方网站上提供偶数题的答案

但是奇数题的答案只能通过寄回书后的回执得到,并且需要加盖学校公章和院系主任签字.

相当麻烦.

2. 《Java语言程序设计基础篇》第六版的练习题和编程题答案


哥们我给你写完了,耽误了我半个小时的时间啊!你直接运行就可以了
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Constellation implements ActionListener{
private JFrame frame = null;
private JTextField year = null;
private JTextField month = null;
private JTextField day = null;
private JLabel label1 = null;
private JLabel label2 = null;
private JLabel label3 = null;
private JPanel panel1 = null;
private JPanel panel2 = null;
private JButton button = null;
private JTextField output = null;
public static final String[] zodiacArr = { "猴", "鸡", "狗", "猪", "鼠", "牛", "虎", "兔", "龙", "蛇",
"马", "羊" };

public static final String[] constellationArr = { "水瓶座", "双鱼座", "牡羊座", "金牛座", "双子座", "巨蟹座",
"狮子座", "处女座", "天秤座", "天蝎座", "射手座", "魔羯座" };

public static final int[] constellationEdgeDay = { 20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22,
22 };

/**
* * 根据日期获取生肖 *
* @return 11.
*/
public static String date2Zodica(Calendar time) {
return zodiacArr[time.get(Calendar.YEAR) % 12];
}

/**
* * 根据日期获取星座 *
* @param time *
* @return
*/
public static String date2Constellation(Calendar time) {
int month = time.get(Calendar.MONTH);
int day = time.get(Calendar.DAY_OF_MONTH);
if (day < constellationEdgeDay[month]) {
month = month - 1;
}
if (month >= 0) {
return constellationArr[month];
}
// default to return 魔羯
return constellationArr[11];
}

public Constellation(){
frame = new JFrame("计算生肖,星座");
year = new JTextField("",3);
month = new JTextField("",3);
day = new JTextField("",3);
label1 = new JLabel("请输入年份:");
label2 = new JLabel(",请输入月份:");
label3 = new JLabel(",请输入日期:");
button = new JButton("查看结果");
button.addActionListener(this);
panel1 = new JPanel();
panel1.setLayout(new FlowLayout(FlowLayout.CENTER));
panel1.add(label1);
panel1.add(year);
panel1.add(label2);
panel1.add(month);
panel1.add(label3);
panel1.add(day);
panel1.add(button);
frame.setLayout(new BorderLayout());
frame.add(panel1,BorderLayout.NORTH);
panel2 = new JPanel();
output = new JTextField("",40);
panel2.add(output,JPanel.CENTER_ALIGNMENT);
frame.add(panel2,BorderLayout.CENTER);
frame.setSize(500, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}

public void actionPerformed(ActionEvent e) {
output.setText("");
int y = Integer.parseInt(year.getText());
int m = Integer.parseInt(month.getText());
int d = Integer.parseInt(day.getText());

Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, y);
calendar.set(Calendar.MONTH, m);
calendar.set(Calendar.DAY_OF_MONTH, d);
String zodica = date2Zodica(calendar);
String constellation = date2Constellation(calendar);
String str = "您输入的日期为:"+y+"年-"+m+"-月"+d+"日,得到的生肖:"+zodica+",星座:"+constellation;
output.setText(str);
}

//testcode
public static void main(String[] args) {
new Constellation();
}
}

3. 求 Java语言程序设计 基础篇 原书第8版 ([美]Y.Daniel Liang 李娜) 课后答案 机械工业出版 课后习题答案

4. 求一份JAVA语言程序设计基础篇(原书第八版)的答案

呃呃呃 好好好

5. 《Java语言程序设计基础篇》机械工程出版社原书第8版 课后习题答案(包括编程题)Liang,Y.D着

这本书在官方网站上提供偶数题的答案

但是奇数题的答案只能通过寄回书后的回执得到,并且需要加盖学校公章和院系主任签字.

6. Java程序设计基础篇课后题答案

http://wenku..com/view/13211a4de518964bcf847cc6.html
http://wenku..com/view/c2fd3a08763231126edb1136.html
不知道是不是

7. Java语言程序设计 基础篇第六版 (Y.Daniel Liang )的,第15 16章的编程题答案

(1)。public class TiaoSeBan extends JFrame {
JPanel panel1;
JPanel toppanel;
JPanel bottompanel;
JPanel colorLabpanel;
JPanel colorScrollBarpanel;
JLabel redLable;
JLabel greenLable;
JLabel blueLable;
JLabel showColorLable;
JScrollBar redScrollBar;
JScrollBar greenScrollBar;
JScrollBar blueScrollBar;
void init(){
panel1=new JPanel();
toppanel=new JPanel();
bottompanel=new JPanel();
colorLabpanel=new JPanel();
colorScrollBarpanel=new JPanel();
redLable=new JLabel("Red");
greenLable =new JLabel("Green");
blueLable=new JLabel("Blue");
showColorLable=new JLabel("Show Colors");
redScrollBar =new JScrollBar(JScrollBar.HORIZONTAL , 0, 100,0,255);
greenScrollBar =new JScrollBar(JScrollBar.HORIZONTAL , 0,100,0,255);
blueScrollBar =new JScrollBar(JScrollBar.HORIZONTAL , 0, 100,0,255);
}
TiaoSeBan(){
super();
init();
setLayout(new BorderLayout());
add(toppanel,BorderLayout.CENTER);
add(bottompanel,BorderLayout.SOUTH);

showColorLable.setHorizontalAlignment(SwingConstants.CENTER);
toppanel.setLayout(new BorderLayout());
toppanel.add(showColorLable,BorderLayout.CENTER);
bottompanel.setLayout(new BorderLayout());
bottompanel.add(colorLabpanel,BorderLayout.WEST);
bottompanel.add(colorScrollBarpanel,BorderLayout.CENTER);
colorLabpanel.setLayout(new GridLayout(3, 1));
colorLabpanel.add(redLable);
colorLabpanel.add(greenLable);
colorLabpanel.add(blueLable);

colorScrollBarpanel.setLayout(new GridLayout(3, 1));
colorScrollBarpanel.add(redScrollBar);
colorScrollBarpanel.add(greenScrollBar);
colorScrollBarpanel.add(blueScrollBar);
redScrollBar.addAdjustmentListener(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
reSetColor(showColorLable);
}
});
greenScrollBar.addAdjustmentListener(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
reSetColor(showColorLable);
}
});
blueScrollBar.addAdjustmentListener(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
reSetColor(showColorLable);
}
});
}
void reSetColor(JLabel label){
label.setForeground(new Color(redScrollBar.getValue(), greenScrollBar.getValue(), blueScrollBar.getValue()));
}
public static void main(String[] args) {
TiaoSeBan frame=new TiaoSeBan();
frame.setTitle("tiaoseban");
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200,200);
frame.setVisible(true);
}
}
(2)public class jisuanq extends JApplet implements ActionListener {
private JTextField jtf = new JTextField(10);
private boolean newNumber = true;
private int result = 0;
private String op = "=";
public void init() {
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
JPanel westPanel = new JPanel();
westPanel.setLayout(new GridLayout(5, 0));
westPanel.add(new JButton(" "));
westPanel.add(new JButton("MC"));
westPanel.add(new JButton("MR"));
westPanel.add(new JButton("MS"));
westPanel.add(new JButton("M+"));
Panel centerPanel = new Panel();
centerPanel.setLayout(new BorderLayout());
Panel p1 = new Panel();
Panel p2 = new Panel();
p1.setLayout(new FlowLayout(FlowLayout.RIGHT));
p1.add(new JButton("Back"));
p1.add(new JButton("CE"));
p1.add(new JButton("C"));
p2.setLayout(new GridLayout(4, 5));
JButton bt;
p2.add(bt = new JButton("7"));
bt.addActionListener(this);
p2.add(bt = new JButton("8"));
bt.addActionListener(this);
p2.add(bt = new JButton("9"));
bt.addActionListener(this);
p2.add(bt = new JButton("/"));
bt.addActionListener(this);
p2.add(bt = new JButton("sqrt"));
bt.addActionListener(this);
p2.add(bt = new JButton("4"));
bt.addActionListener(this);
p2.add(bt = new JButton("5"));
bt.addActionListener(this);
p2.add(bt = new JButton("6"));
bt.addActionListener(this);
p2.add(bt = new JButton("*"));
bt.addActionListener(this);
p2.add(bt = new JButton("%"));
bt.addActionListener(this);
p2.add(bt = new JButton("1"));
bt.addActionListener(this);
p2.add(bt = new JButton("2"));
bt.addActionListener(this);
p2.add(bt = new JButton("3"));
bt.addActionListener(this);
p2.add(bt = new JButton("-"));
bt.addActionListener(this);
p2.add(bt = new JButton("1/x"));
bt.addActionListener(this);
p2.add(bt = new JButton("0"));
bt.addActionListener(this);
p2.add(bt = new JButton("+/-"));
bt.addActionListener(this);
p2.add(bt = new JButton("."));
p2.add(bt = new JButton("+"));
bt.addActionListener(this);
p2.add(bt = new JButton("="));
bt.addActionListener(this);
centerPanel.add(p2, BorderLayout.CENTER);
centerPanel.add(p1, BorderLayout.NORTH);
p.add(centerPanel, BorderLayout.CENTER);
p.add(westPanel, BorderLayout.WEST);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(p, BorderLayout.CENTER);
getContentPane().add(jtf, BorderLayout.NORTH);
}
public void actionPerformed(ActionEvent e) {
String actionCommand = e.getActionCommand();
if ('0' <= actionCommand.charAt(0) &&
actionCommand.charAt(0) <= '9') {
if (newNumber) {
jtf.setText(actionCommand);
newNumber = false;
}
else {
jtf.setText(jtf.getText() + actionCommand);
}
}
else
if (newNumber) {
if (actionCommand.equals("-")) {
jtf.setText("-");
newNumber = false;
}
else
op = actionCommand;
}
else {
execute();
op = actionCommand;
}
}
void execute() {
int number = new Integer(jtf.getText()).intValue();
System.out.println("number " + op);
switch (op.charAt(0)) {
case '+': result += number; break;
case '-': result -= number; break;
case '*': result *= number; break;
case '/': result /= number; break;
case '%': result %= number; break;
case '=': result = number;
}
System.out.println("result "+result);
jtf.setText(new Integer(result).toString());
newNumber = true;
}
/**This main method enables the applet to run as an application*/
public static void main(String[] args) {
// Create a frame
JFrame frame = new JFrame("Exercise16_8");
// Create an instance of the applet
jisuanq applet = new jisuanq();
// Add the applet instance to the frame
frame.getContentPane().add(applet, BorderLayout.CENTER);
// Invoke init() and start()
applet.init();
applet.start();

// Display the frame
frame.setSize(300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}

8. java程序设计上机题,求答案

public class Point {
int x;
int y;

public Point() {
}

public Point(int x, int y) {
this.x = x;
this.y = y;
}

public Point(int x) {
this.x = x;
this.y = x;
}

public double distance() {//求当前点到原点的距离
return Math.sqrt((x * x + y * y));
}

public double distance(int x1, int y1) {//求当前点到(x1,y1)的距离
return Math.sqrt((x-x1)*(x-x1) + (y-y1) * (y-y1));
}
public double distance(Point other){
int x2 = other.x;
int y2 = other.y;
return Math.sqrt((x-x2)*(x-x2) + (y-y2) * (y-y2));
}
}

9. 求 Java语言程序设计 基础篇 原书第10版 ([美]Y.Daniel Liang 李娜) 课后答案

答案家有这个答案,前段时间我上传了的。在答案家的大学课后答案的计算机类的目下

热点内容
linux上传本地文件到服务器 发布:2025-01-06 06:01:20 浏览:496
c语言编译过程讲解 发布:2025-01-06 05:52:42 浏览:693
安卓的光遇怎么华丽退场 发布:2025-01-06 05:50:27 浏览:680
腾讯云轻量服务器设置独立ip 发布:2025-01-06 05:50:26 浏览:722
服务器的主机地址 发布:2025-01-06 05:47:38 浏览:869
为什么安卓系统最近越来越多更新 发布:2025-01-06 05:47:30 浏览:956
如何用cmd打开服务器管理器 发布:2025-01-06 05:44:40 浏览:436
我的世界国际服一进服务器就崩 发布:2025-01-06 05:30:53 浏览:395
云主机网站源码 发布:2025-01-06 05:30:40 浏览:88
整数指数幂的运算法则 发布:2025-01-06 05:22:32 浏览:362