
正文
java生成课程表代码 java编写课程表
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
请帮我用JAVA数组的方式编写一个课程表,感激不尽!
public class IdUtil {
public static void main(String[] args) {
//七天java生成课程表代码的课程
String[] week = new String[7];
//每天java生成课程表代码的课程名
week[0] = "语文,语文,语文,语文,语文,语文,语文,语文,语文,语文";
week[1] = "数学,数学,数学,数学,数学,数学,数学,数学,数学,数学";
week[2] = "外语,外语,外语,外语,外语,外语,外语,外语,外语,外语";
week[3] = "物理,物理,物理,物理,物理,物理,物理,寂寞学,物理,物理";
week[4] = "化学,化学,化学,化学,化学,化学,化学,化学,化学,化学";
week[5] = "生物,生物,生物,生物,生物,生物,生物,生物,生物,生物";
week[6] = "寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学";
//上课时间
String[] time = {"8:00","9:00","8:00","8:00","8:00","8:00","8:00","8:00","8:00","8:00"};
for(int a=1;a8;a++){
System.out.print("\t"+"星期"+a);
}
System.out.println();
int b = 0;
for(int i=1;i11;i++){
switch (i) {
case 1:
System.out.println("上午");
break;
case 5:
System.out.println("下午");
break;
case 9:
System.out.println("晚上");
break;
}
System.out.print(time[i-1]+"\t");
for(int j=0;j7;j++){
System.out.print(week[j].split(",")[b]+"\t");
}
System.out.println();
b++;
}
}
}
相关问答
Q1: 创建一个完整Java程序,完成以下任务:输出本学期自己的课程表。
我来给你回答咯~呵呵
import java.util.Random;
public class MyLesson{
//定义常量字符串
public static String ch="语文\t";
public static String math="数学\t";
public static String en="英语\t";
public static String bio="物理\t";
public static String phy="化学\t";
//还有很多节约时间自己写吧
public static void main(String args[]){
System.out.println("\t\tMy Lessons");
for(int i=1;i7;i++){
System.out.print("星期"+i+"\t");
for(int j=1;j=6;j++){
//有多少课就写几次
switch(new Random().nextInt(5)){
case 0:
System.out.print(ch);
break;
case 1:
System.out.print(math);
break;
case 2:
System.out.print(en);
break;
case 3:
System.out.print(bio);
break;
case 4:
System.out.print(phy);
break;
}
}
System.out.println();
}
}
}输出结果:
My Lessons
星期1 物理 数学 数学 物理 数学 数学
星期2 物理 英语 化学 数学 英语 化学
星期3 语文 数学 数学 化学 化学 物理
星期4 语文 英语 数学 化学 物理 物理
星期5 英语 数学 物理 物理 化学 物理
星期6 化学 化学 英语 数学 数学 物理
Q2: 有没有大佬会用Java制作一个课程表?
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Vector;
public class Scholl_Timetble {
static String[] RequiredCourse = { "语文", "数学", "英语", "历史", "政治", "地理", "化学", "物理", "生物" };
static String[] Elective = { "体育", "音乐", "美术" };
static VectorInteger vectorElective = new Vector();
// 随机选修课数组索引集合
static VectorInteger vectorRequiredCourse = new Vector();
// 随机必修课数组索引集合
static VectorInteger vectorDay = new Vector();
// 随机天集合
static VectorInteger vectorLession = new Vector();
// 随机课集合
static VectorInteger vectorRequiredCourse() {
// 随机必修课方法
LinkedHashSetInteger linkedHashSet = new LinkedHashSet();
if (!linkedHashSet.isEmpty()) {
linkedHashSet.clear();
}
while (linkedHashSet.size() RequiredCourse.length) {
linkedHashSet.add((int) (Math.random() * RequiredCourse.length));
}
linkedHashSet.forEach(x - vectorRequiredCourse.add(x));
return vectorRequiredCourse;
}
static VectorInteger vectorElective() {
// 随机选修课方法
LinkedHashSetInteger linkedHashSet = new LinkedHashSet();
while (linkedHashSet.size() Elective.length) {
linkedHashSet.add((int) (Math.random() * Elective.length));
}
linkedHashSet.forEach(x - vectorElective.add(x));
return vectorElective;
}
static VectorInteger vectorDay() {
// 随机天方法
LinkedHashSetInteger linkedHashSet = new LinkedHashSet();
while (linkedHashSet.size() Elective.length) {
linkedHashSet.add((int) (1 + Math.random() * 5));
}
linkedHashSet.forEach(x - vectorDay.add(x));
return vectorDay;
}
static VectorInteger vectorLession() {
// 随机课方法
LinkedHashSetInteger linkedHashSet = new LinkedHashSet();
while (linkedHashSet.size() Elective.length) {
linkedHashSet.add((int) (1 + Math.random() * 7));
}
linkedHashSet.forEach(x - vectorLession.add(x));
return vectorLession;
}
public static void main(String[] args) {
String s[] = { "一", "二", "三", "四", "五" };
vectorDay();
Collections.sort(vectorDay);
vectorLession();
Collections.sort(vectorLession);
vectorElective();
for (int i1 = 1; i1 6; i1++) {
vectorRequiredCourse();
for (int i = 1; i 8; i++) {
if (i == 1)
System.out.print("\n周" + s[i1 - 1] + "\t");
int i2 = 0;
for (int i3 = 0; i3 vectorElective.size(); i3++) {
if (vectorDay.get(i3) == i1 vectorLession.get(i3) == i) {
System.out.print(Elective[vectorElective.get(i3)] + "\t");
break;
} else if (i2 == vectorElective.size() - 1) {
System.out.print(RequiredCourse[vectorRequiredCourse.get(i - 1)] + "\t");
}
i2++;
}
}
System.out.println();
vectorRequiredCourse.removeAllElements();
}
}
}
这个课程表每天无重复课程,如果要想有重复的需要加条件
关于java生成课程表代码和java编写课程表的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。





