package hotel;
import java.util.Scanner;
public class HotelManager { private static String[][] rooms;// 表示房间 public static void main(String[] args) { rooms = new String[10][12]; String comm;// 表示用户输入的命令 for (int i = 0; i < rooms.length; i++) { for (int j = 0; j < rooms[0].length; j++) { rooms[i][j] = \ } } // while (true) { System.out.println(\请输入命令:\ Scanner sca = new Scanner(System.in); System.gc(); comm = sca.next(); if (\ search(); } else if (\ int roomNo = sca.nextInt(); String name = sca.next(); in(roomNo, name); } else if (\ int roomNo = sca.nextInt(); out(roomNo); } else if (\ System.out.println(\程序退出...\ break; } else { System.out.println(\命令输入错误,请重新输入:\ } } } private static void out(int roomNo) { if(\ System.out.println(\该房间没有客人入住,退房失败!\
}
return; }
rooms[(roomNo/100)-1][(roomNo0)-1]=\System.out.println(roomNo+\退房成功!\
private static void in(int roomNo, String name) { if(!\ System.out.println(\该房间已经有客人入住!\ return; } rooms[(roomNo/100)-1][(roomNo0)-1]=name; System.out.println(name+\成功入住\房间!\ }
private static void search() { for (int i = 0; i < rooms.length; i++) { //打印房间号 for (int j = 0; j < rooms[0].length; j++) { if (j + 1 < 10) { System.out.print(i + 1 + \\ } else { System.out.print(i + 1 + \ } } //打印房间状态 System.out.println(); for (int j = 0; j < rooms[0].length; j++) { System.out.print(rooms[i][j] + \\ } System.out.println(); } }
}
18.StudentManager
package day05.student_manager; import java.util.Scanner;
public class StudentManager { static int[][] scores=new int[6][5]; static String[] students={\ static String[] courses={\ public static void main(String[] args) { for(int i=0;i // int cIndex=-1; for(int i=0;i public static void sort(String course){ int[] courseScore=new int[scores.length]; if(course.equals(\如果求总分的排名 //求出每个学生的总分,将成绩存放在courseScore数组中 for(int i=0;i courseScore[i]=studentSum; } }else{//如果不是求总分排名 int cIndex=-1; for(int i=0;i String[] studentCopy=new String[students.length]; System.arraycopy(students, 0, studentCopy, 0, students.length); for(int i=0;i int order=1; System.out.println(\名次\\t学生\\t成绩\for(int i=0;i