本文目錄一覽:
求大神幫做java web的期末課程設計,急用,我要成品,不需要太複雜!!!
代碼自己敲啊。。。。沒有難度的啊 。。。熟悉一下,web、servlet的配置。
回收站,就搞一個邏輯刪除就OK 了。
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)
樓上的都理解錯了把,樓主應該做的是用Swing和Awt做的桌面應用程序把。如果做的是Web,界面根本沒java什麼事。用Swing做的界面在windows上的確很難看。這不是你能改變的。樓主可以嘗試用SWT來做。Eclipse就是用SWT做的,即便如此,做出來的界面也稱不上很棒。如果樓主不嫌麻煩,可以自己動手做一些圖片作為窗口和控件的背景,這需要美術基礎。
JSP基於WEB的名片管理系統
做畢業設計呢吧?做這個要先把平台搭建起來啊,你所用的服務器是是什麼,數據庫是什麼,先要知道,然後才是選用的軟件以及其的配置,之後就是要把數據庫的東西弄好,數據庫中有幾個表格,表格中各個字段所需要的字符類型,大小,這個你要先設計出來。然後就是開始登陸的部分,登陸後用戶的權限的問題,每個人都要看到自己的用戶名片,就是和自己的id主鍵相連,輸入id後,用戶就調用自己的名片頁面…這樣的話還是很多的知識的,在這個裡面是說不明白的。建議你最好買本這方面的書來看看,沒有人會在這裡面說的那麼詳細的。希望你成功。
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/287060.html