-
Notifications
You must be signed in to change notification settings - Fork 0
/
Outline.java
81 lines (60 loc) · 3.3 KB
/
Outline.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class CourseOutline {
public static void main(String[] args) {
String teacherName = "Shamsa Kanwal";
int creditHours = 3;
String roomNumber = "410 - 100 Campus";
String courseDay = "Thursday";
String[][] courseContent = {
{"1", "Introduction to Linear Algebra", "Week 1"},
{"2", "Matrix Operations", "Week 2"},
{"3", "Determinants and Inverses", "Week 3"},
{"4", "Vector Spaces", "Week 4"},
{"5", "Linear Transformations", "Week 5"},
{"6", "Eigenvalues and Eigenvectors", "Week 6"},
{"7", "Diagonalization", "Week 7"},
{"8", "Orthogonality and Projections", "Week 8"},
{"9", "Inner Product Spaces", "Week 9"},
{"10", "Gram-Schmidt Process", "Week 10"},
{"11", "Least Squares Solutions", "Week 11"},
{"12", "Applications in Comp Graphics", "Week 12"},
{"13", "Final Project Discussion", "Week 13"},
{"14", "Complex Vector Spaces", "Week 14"},
{"15", "Numerical Methods", "Week 15"},
{"16", "Final Project Submission", "Week 16"}
};
printCourseOutline(teacherName, creditHours, roomNumber, courseDay, courseContent);
}
public static void printCourseOutline(String teacherName, int creditHours, String roomNumber, String courseDay, String[][] courseContent) {
String border = "===========================================================";
String header = "Linear Algebra Course Outline";
String divider = "-----------------------------------------------------------";
int consoleWidth = 135;
int contentWidth = border.length();
System.out.println(centerText(border, consoleWidth));
System.out.println(centerText(header, consoleWidth));
System.out.println(centerText(border, consoleWidth));
System.out.println(centerText("Teacher's Name: " + teacherName, consoleWidth));
System.out.println(centerText("Credit Hours: " + creditHours, consoleWidth));
System.out.println(centerText("Room Number: " + roomNumber, consoleWidth));
System.out.println(centerText("Course Day: " + courseDay, consoleWidth));
System.out.println(centerText(border, consoleWidth));
String tableHeader = String.format("| %-10s | %-30s | %-10s |", "Sr. No.", "Content", "Week");
System.out.println(centerText(tableHeader, consoleWidth));
System.out.println(centerText(divider, consoleWidth));
for (String[] row : courseContent) {
String tableRow = String.format("| %-10s | %-30s | %-10s |", row[0], row[1], row[2]);
System.out.println(centerText(tableRow, consoleWidth));
}
System.out.println(centerText(border, consoleWidth));
}
public static String centerText(String text, int width) {
int padding = (width - text.length()) / 2;
if (padding < 0) padding = 0;
StringBuilder result = new StringBuilder();
for (int i = 0; i < padding; i++) {
result.append(" ");
}
result.append(text);
return result.toString();
}
}