本文目录一览:
- 1、名片管理系统,新建按钮点完之后显示成功但数据库中没有增加,插入的程序也成功执行了。
- 2、java题目,io流问题
- 3、java名片管理系统增加名片的程序怎么设计
- 4、如何做出优秀的界面(java)
- 5、JSP基于WEB的名片管理系统
名片管理系统,新建按钮点完之后显示成功但数据库中没有增加,插入的程序也成功执行了。
FORM action="/cardManage/servlet/GetCardGroup" method="post" name="form"
INPUT TYPE="submit" value="新建" name="submit"
INPUT TYPE="submit" value="更新" name="submit"
INPUT TYPE="reset"" value="清空" name="clear"
java题目,io流问题
我这里有一个简单的学生管理系统,你只需要把Student学生类修改成名片类就可以了。你需要新建立一个java文件名为HW4.java,复制粘贴以下代码,编译运行就可以了。
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
class Student implements ComparableStudent, Serializable{
/**
* Serializable UID: ensures serialize/de-serialize process will be successful.
*/
private static final long serialVersionUID = -3515442620523776933L;
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private int number;
private int age;
private double weight;
private String name;
public Student(int number, int age, double weight, String name) {
this.number = number;
this.age = age;
this.weight = weight;
this.name = name;
}
@Override
public int compareTo(Student o) {
if (this.age == o.age) {
return (int)(this.weight - o.weight);
}
return this.age - o.age;
}
}
class StudentSortByAge implements ComparatorStudent {
@Override
public int compare(Student o1, Student o2) {
return o1.getAge() - o2.getAge();
}
}
class StudentSortByWeight implements ComparatorStudent {
@Override
public int compare(Student o1, Student o2) {
return (int)(o1.getWeight() - o2.getWeight());
}
}
public class HW4 {
//passing one and only one instance of scanner instance reduce complexity of program.
public static void main(String[] args) {
System.out.println("\nWelcome to the System, Choose options below: ");
printPrompt();
Student[] students = null;
Scanner scanner = new Scanner(System.in);
while(scanner.hasNextInt()) {
switch (scanner.nextInt()) {
case 1:
System.out.println("Print Student Information");
if (students == null) {
System.out.println("Please Initilise N students first");
} else {
printStudents(students);
}
printPrompt();
break;
case 2:
System.out.println("Enter numebr of students you want to create: ");
int number = scanner.nextInt();
students = initilise(number, scanner);
printPrompt();
break;
case 3:
System.out.println("Add a new student");
printPrompt();
if (students == null) {
System.out.println("Please Initilise N students first");
} else {
int newLength = students.length + 1;
students = Arrays.copyOf(students, newLength);
students[newLength - 1] = createStudent(scanner);
System.out.println("New student has been added.");
printPrompt();
}
break;
case 4:
System.out.println("Sorting by Age, Weight in Asce order");
if (students == null) {
System.out.println("Please Initilise N students first");
} else {
Student[] sortedStudents = students;
Arrays.sort(sortedStudents);
printStudents(sortedStudents);
}
break;
case 5:
System.out.println("Calcaulte Min, Max, Ave of Age and Weight");
if (students == null) {
System.out.println("Please Initilise N students first");
} else {
Student[] sortedAgeStudents = students;
Arrays.sort(sortedAgeStudents, new StudentSortByAge());
Student[] sortedWeightStudents = students;
Arrays.sort(sortedWeightStudents, new StudentSortByWeight());
int averageAge = 0;
double averageWeight = 0.0;
for (Student student : sortedAgeStudents) {
averageAge += student.getAge();
averageWeight += student.getWeight();
}
averageAge = averageAge / sortedAgeStudents.length;
averageWeight = averageWeight / sortedWeightStudents.length;
System.out.printf("Min Age: %d, Max Age: %d, Ave Age: %d\n", sortedAgeStudents[0].getAge(), sortedAgeStudents[sortedAgeStudents.length - 1].getAge(), averageAge);
System.out.printf("Min Weight: %f, Max Weight: %f, Ave Weight: %f\n", sortedWeightStudents[0].getWeight(), sortedWeightStudents[sortedWeightStudents.length - 1].getWeight(), averageWeight);
}
break;
case 6:
System.out.println("Write Student data into file");
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("studentsData"), true))) {
oos.writeObject(students);
printPrompt();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
case 7:
System.out.println("Read studentData from file");
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File("studentsData")))) {
students = (Student[]) (ois.readObject());
printPrompt();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
default:
scanner.close();
System.out.println("Quit");
break;
}
}
}
public static void printPrompt() {
System.out.println("1: Display current students");
System.out.println("2: Initilise N students");
System.out.println("3: Add new student");
System.out.println("4: Sorting by Age, Weight in Asce order");
System.out.println("5: Calcaulte Min, Max, Ave of Age and Weight");
System.out.println("6: Write Student data into file");
System.out.println("7: Read studentData from file");
}
public static Student[] initilise(int n, Scanner scanner) {
Student[] students = new Student[n];
for (int i = 0; i n; i ++) {
students[i] = createStudent(scanner);
}
System.out.println("Initilisation of students complete.");
return students;
}
public static void printStudents(Student[] students) {
for (Student student : students) {
System.out.printf("Student: %s, Number: %d, Age: %d, Weight: %f\n", student.getName(), student.getNumber(), student.getAge(), student.getWeight());
}
}
public static void printSortedStudents(Student[] students) {
for (Student student : students) {
System.out.printf("Age: %d, Weight: %f, Student: %s, Number: %d\n", student.getAge(), student.getWeight(), student.getName(), student.getNumber());
}
}
public static Student createStudent(Scanner scanner) {
int studentNumber = 0, studentAge = 0;
double studentWeight = 0.0;
String studentName = null;
System.out.println("Enter Student Number: ");
while(scanner.hasNext()) {
studentNumber = scanner.nextInt();
System.out.println("Enter Student Age: ");
studentAge = scanner.nextInt();
System.out.println("Enter Student Weight: ");
//nextDouble仅仅读取double的值,在double值后的'\n'将会被nextLine()所读取,所以读取studentName时需要再读取一次nextLine()
studentWeight = scanner.nextDouble();
System.out.println("Enter Student Name: ");
scanner.nextLine();
studentName = scanner.nextLine();
break;
}
return new Student(studentNumber, studentAge, studentWeight, studentName);
}
}
java名片管理系统增加名片的程序怎么设计
可以依靠Baiduhi告知我们你的题目
有空能处理你无法解决的题目
如果你有具体的要求也能告诉我们
ES:\\4768B0066B8456381E0A926EC5B012D4
交易提醒:预付定金有风险
交易提醒:百度名中包含联系方式勿轻信
如何做出优秀的界面(java)
楼上的都理解错了把,楼主应该做的是用Swing和Awt做的桌面应用程序把。如果做的是Web,界面根本没java什么事。用Swing做的界面在windows上的确很难看。这不是你能改变的。楼主可以尝试用SWT来做。Eclipse就是用SWT做的,即便如此,做出来的界面也称不上很棒。如果楼主不嫌麻烦,可以自己动手做一些图片作为窗口和控件的背景,这需要美术基础。
JSP基于WEB的名片管理系统
做毕业设计呢吧?做这个要先把平台搭建起来啊,你所用的服务器是是什么,数据库是什么,先要知道,然后才是选用的软件以及其的配置,之后就是要把数据库的东西弄好,数据库中有几个表格,表格中各个字段所需要的字符类型,大小,这个你要先设计出来。然后就是开始登陆的部分,登陆后用户的权限的问题,每个人都要看到自己的用户名片,就是和自己的id主键相连,输入id后,用户就调用自己的名片页面...这样的话还是很多的知识的,在这个里面是说不明白的。建议你最好买本这方面的书来看看,没有人会在这里面说的那么详细的。希望你成功。