Java作业求助
public class Hw6_4 {
public static void main(String[] args) {
int[] a = new int[]{1,4,9,16};
int[] b = new int[]{9,7,4,9,11,20,5};
int[] c;
int i;
System.out.println("before merge : ");
System.out.print("a : ");
for(i=0; i<a.length; i++){
System.out.print(a[i] + " ");
}
System.out.print("
b : ");
for(i=0; i<b.length; i++){
System.out.print(b[i] + " ");
}
c = merge(a, b);
System.out.println("
after merge : ");
System.out.print("c : ");
for(i=0; i<c.length; i++){
System.out.print(c[i] + " ");
}
System.out.println();
}
public static int[] merge(int[] a, int[] b){
int lenA, lenB;
int i, j, k = 0;
lenA = a.length;
lenB = b.length;
int[] c = new int[lenA + lenB];
for(i=0,j=0,k=0; i<lenA && j<lenB; i++,j++){
c[k++] = a[i];
c[k++] = b[j];
}
for(; i < lenA; i++,k++){
c[k] = a[i];
}
for(; j<lenB; j++,k++){
c[k] = b[j];
}
return c;
}
}
封装学生类:
public class Student { private String name;//姓名 private int age;//年龄 private String sex;//性别 private Date birthday;//生日 public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; }}利用继承计算形状的面积
形状类:
public abstract class Shape { public abstract double area();}正方形类:
public class Square extends Shape { private double side; public Square(double side) { this.side = side; } @Override public double area() { return side*side; }}长方形类:
public class Rectangle extends Shape { private double length; private double width; public Rectangle(double length, double width) { super(); this.length = length; this.width = width; } @Override public double area() { return length*width; }}测试类:
public class Test { public static void main(String[] args) { Shape shape = new Rectangle(20,10); System.out.println("长方形面积是:" + shape.area()); shape = new Square(20); System.out.println("正方形面积是:" + shape.area()); }}输出:
长方形面积是:200.0正方形面积是:400.0
{
private String name;
private long num;
private int age;
private String phone;
private int classid;
//构造方法1
public Student(String name,long num)
{
this.name=name;
this.num=num;
}
//构造方法2
public Student(String name,long num,int age)
{
this.name=name;
this.num=num;
this.age=age;
}
//构造方法3
public Student(String name,long num,int age,String phone,int classid)
{
this.name=name;
this.num=num;
this.age=age;
this.phone=phone;
this.classid=classid;
}
public void showMessage()
{
System.out.println("姓名:"+name);
System.out.println("学号:"+num);
System.out.println("年龄:"+age);
System.out.println("电话:"+phone);
System.out.println("班级号:"+classid);
}
}
public class Test
{
public static void main(String args[])
{
Student stu1=new Student(姓名1,学号1);
stu1.showMessage();
Student stu2=new Student(姓名2,学号2,年龄2);
stu2.showMessage();
Student stu3=new Student(姓名3,学号3,年龄3,电话3,班级号3);
stu3.showMessage();
}
}
package org.dxf;
public class Student {
String name;
int num;
int age;
String phone;
String classid;
public Student(String name,int num){
setName(name);
setNum(num);
}
public Student(String name,int num,int age){
setName(name);
setNum(num);
setAge(age);
}
public Student(String name,int num,int age,String phone,String classid){
setName(name);
setNum(num);
setAge(age);
setPhone(phone);
setClassid(classid);
}
public void showMessage(){
System.out.println("name"+getName());
//省略其他的,自己去写
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getClassid() {
return classid;
}
public void setClassid(String classid) {
this.classid = classid;
}
}
package org.dxf;
public class studentTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s1=new Student("1", 1, 1, "1", "1");
Student s2=new Student("2", 2, 2, "2", "2");
Student s3=new Student("3", 3, 3, "3", "3");
Student s4=new Student("4", 4, 4, "4", "4");
s1.showMessage();
s2.showMessage();
s3.showMessage();
s4.showMessage();
}
}
public class Student
{
private String name;
private long num;
private int age;
private String phone;
private int classid;
//构造方法1
public Student(String name,long num)
{
this.name=name;
this.num=num;
}
//构造方法2
public Student(String name,long num,int age)
{
this.name=name;
this.num=num;
this.age=age;
}
//构造方法3
public Student(String name,long num,int age,String phone,int classid)
{
this.name=name;
this.num=num;
this.age=age;
this.phone=phone;
this.classid=classid;
}
public void showMessage()
{
System.out.println("姓名:"+name);
System.out.println("学号:"+num);
System.out.println("年龄:"+age);
System.out.println("电话:"+phone);
System.out.println("班级号:"+classid);
}
}
public class Test
{
public static void main(String args[])
{
Student stu1=new Student("张三",001,16,"80000000",1);
Student stu2=new Student("李四",002,15,"66668888",1);
Student stu3=new Student("王五",003,16,"62345678",1);
stu1.showMessage();
stu2.showMessage();
stu3.showMessage();
}
}
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s1 = new Student("张三",001,25,12535673,"二年五班");
Student s2 = new Student("李四",002,22,12535674,"二年五班");
Student s3 = new Student("王五",003,23,12535675,"二年五班");
Student s4 = new Student("马二",004,24,12535676,"二年五班");
s1.showMessage();
s2.showMessage();
s3.showMessage();
s4.showMessage();
}
}
class Student{
String name = null;
int age = 0;
int num = 0;
long phone= 0;
String classid = null;
public Student(String name,int num){
this.name = name ;
this.num = num;
}
public Student(String name,int num,int age){
this.name = name;
this.num = num;
this.age = age;
}
public Student(String name,int num,int age ,long phone,String classid){
this.name = name;
this.num = num;
this.age = age ;
this.phone = phone;
this.classid = classid;
}
public void showMessage(){
System.out.println("name : " + name );
System.out.println("num : " + num);
System.out.println("age : " + age);
System.out.println("phone : " + phone);
System.out.println("classid : "+ classid );
}
}
同志们啊!同志们啊!同志们啊!同志们啊!同志们啊!同志们啊!同志们啊!同志们啊!同志们啊!同志们啊!同志们啊!同志们啊!同志们啊!
这充分凸显了百度知道的缺陷啊!害人啊!
这种问题,还是不回答得好啊!
java作业
1.安装jdk并配置环境变量 下载:jdk1.5.0_08:有了这个安装程序,你就可以开发和运行跟JAVA有关的程序 按照JDK的提示来安装,安装完之后设置环境变量 JDK环境变量配置的步骤如下:1.我的电脑-->属性-->高级-->环境变量.2.配置用户变量:a.新建 JAVA_HOME C:\\Program Files\\Java\\j2sdk1.5.0 ...
无法识别字符串类型ava.sql.SQLDataException求大神看看这是期末作业秋...
你看下你前台传过来的值,哪个是gasfg,然后找到这个属性。你表中的这个字段对应的是double,你直接给个不是数值的字符串,肯定是错的。要传递一个数值
英语作业急急急 be+Ving (am,is,ava)别造三个句子共九句
I am talking with you.I am sleeping,I am running to school.He is laughing at the student.She is eating her lunch.He is doing his homework.They are playing computer games.You are burning the paper.They are drinking water.给个采纳吧 o(∩_∩)o ...
玩AVA(战地之王)上YY玩游戏就死机,单独上YY或游戏都没问题,求高手指教...
4:AVA是一个占用资源很大的游戏,不是说要多高的配置,而是占用你本身拥有的配置的百分比所以会卡,有可能你系统或电脑在处理这些方面有点蛋疼5:极小概率的情况:好像TX出了软件叫QT的··· 来自:求助得到的回答 已赞过 已踩过< 你对这个回答的评价是? 评论 收起 DLAMwsz 2012-12-26 · TA获得超过262...
求一个AVA体验服1198的升级补丁名字是AVA_T_Client_patch_Ver.1198_11...
游戏简称:AVA 引擎:虚幻引擎3(虚幻引擎3)国内电信运营商:腾讯作品> “战地之王游戏本身是免费的,玩家可以自由官方网站下载正式版的游戏玩家获得的记录,您将获得一定数额的打钱的玩家可以使用打钱购买更高端的设备价值的损失,损失的设备维护需要玩家打钱,一些高端武器需要AVA点购买。中心的游戏充值AVA点或支付。AVA武器,...
我的英文电影赏析作业要拍个小视频 剧本差不多了 请大家帮忙想想男女主 ...
克里斯多佛Christopher 艾登Aiden 马修Matthew 大卫David 安德鲁Andrew 女生 伊莎贝拉Isabella 艾玛Emma 奥利维亚Olivia 索菲娅Sophia 艾娃Ava 艾蜜莉Emily 麦迪逊Madison 阿比盖尔Abigail 克洛艾Chloe 米娅Mia 伊丽莎白Elizabeth 艾迪森Addison 亚历克西斯Alexis 埃拉Ella 萨曼塔Samantha ...
怎么让自己摆脱LOL,太过于沉迷,作业都差点没写...
其实我认为真的没必要摆脱,lol它也给我们带来了不少快乐是不是,如果说太沉迷只能说是你的问题,一般这种情况就是给自己的压力不够,闲着没事干又不想做作业是不是?我以前也有这样的情况,给自己找点事做就不会有这种感觉了,比如我想给我喜欢的英雄亲手弄个皮肤专门去学了模型,要知道我以前也是...
想找一款比较实用的蓝牙耳机,有推荐吗?
作为一个数码控,每次打开抽屉就会发现玲琅满目的各式各样的蓝牙耳机,买这么多蓝牙耳机,也是有宝藏耳机,当然也踩过不少坑,今天给大家推荐几款平价好用的蓝牙耳机,618将至,需要的可以直接抄作业啦!xisem西圣Ava蓝牙耳机 售价:119元 Xisem西圣蓝牙耳机品牌在数码圈内的口碑非常高,销量在平价蓝牙耳机...
求多部电影多介绍点
WALL·E是大公司Buy n Large制作的清理地球垃圾的低等机器人,人类早已移民外星球,留下自由作业的WALL·E,打算用几百年的时间打扫地球。时间过去得很快,几乎所有的WALL·E都已经过了使用期限,纷纷坏机,唯独剩下一只,我们姑且就叫它瓦力吧。身为机器人的瓦力非但没有坏机,甚至还渐渐有了人类的情感。地球依然很脏,...
中国太平保险5000元保险
你购买的应该是中国太平的 盈盛C款 这个产品。该业务的特色是:保本、免税、每年领取10%基本保额,且随分红每年递增;每年存钱每年领钱,存10年领15年;15年期满可一次领取所交全部保费及累计红利;还可附加住院医疗保障及18种重大疾病保障。这是属于分红型保险,属于保值增值型理财产品,是没有风险的...
除和扶正: 你每个题目建立一个文件夹 然后把你的.java的source文件放到对应的文件夹里面 然后压缩成一个zip文件,发给你老师 在邮件里面写上你是怎么放文件的 就可以了
高平市15694899555: java小作业,麻烦高手解答!急求!谢谢?
除和扶正: package superclass public class Sharp {final static double PI=3.14; } package subclass import superclass public class Rectangles extends Sharps {private double length,width;public Rectangles(){length = 0.0;width =0.0;}public double ...
高平市15694899555: 急"'求助JAVA作业.?
除和扶正: package com.bean; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class lianliankan implements ActionListener { JFrame mainFrame; //主面板 Container thisContainer; JPanel centerPanel,southPanel,northPanel; //子面板...
高平市15694899555: java练习题求助 - ?
除和扶正: 发现了两个错误: public static void main(String[] args) { Employee e1 = new Employ...
高平市15694899555: 一道JAVA题.求助... - ?
除和扶正: 给你Account类测试类你要是要就说:public class Account { //属性:账号(account)、储户姓名(name)、地址(addr)、存款余额(balance)、最小余额(min,设为10元.存折中最小必须留有的额度,适合所有储户) // 除min外,均为私...
高平市15694899555: Java作业求助?
除和扶正: scanner input=new scanner(system.in) int scode=input.nextInt(); if scode>100 system.out.print("输入错误") else if scode>90 system.out.print("优秀") else if(scode>70&&scode<89) system.out.print("一般") else if(scode>60&&scode<79) system.out.print("及格") else system.out.print("不及格") 不是74是79吧
高平市15694899555: java编写简单的记事本程序!!求助!作业!请附带稍微详细一点的文档说明!说明都有什么,怎么运行!! - ?
除和扶正: 给你个做好了的Java的源程序的记事本,自己看看就行了的,不怎么难的··· 文件名 MyNotepad .java import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.*; public class MyNotepad implements ActionListener{ private ...
高平市15694899555: java菜鸟作业请教!~ - ?
除和扶正: 第二个先给你import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Calculator extends JFrame{ private JTextField tf1 = new JTextField(10); private JTextField tf...
高平市15694899555: 有个java作业,哪位高手帮忙解决下,谢谢!?
除和扶正: public class Student { private int id; private String name; public Student(){} public Student(int id,String name){ this.id=id; this.name=name; }public int getId() { return id; }public void setId(int id) { this.id = id; }public String getName() { return name; }...
高平市15694899555: 帮忙解决一个java作业.. - ?
除和扶正: public class Somme { public static void main(String args[]) throws Exception{ if(args.length==1) throw new OnlyOneException("only one ");else if(args.length==0) throw new NoOprandException("No oprand "); else if(args.length==2) System....