-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_7_6.java
More file actions
70 lines (61 loc) · 2.14 KB
/
Example_7_6.java
File metadata and controls
70 lines (61 loc) · 2.14 KB
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
package unit_07.Examples.Example_06;
import java.util.Scanner;
public class Example_7_6 {
private static Student[] dayStudents;
private static NightStudent[] nightStudents;
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
askNumberOfStudents();
while (true) {
switch (menu()) {
case 1 -> enterDataDs();
case 2 -> showDataDs();
case 3 -> enterDataNs();
case 4 -> showDataNs();
case 0 -> System.exit(0);
default -> System.out.println("Invalid Option! ");
}
}
}
public static void askNumberOfStudents() {
System.out.println("How many daily students? ");
dayStudents = new Student[sc.nextInt()];
System.out.println("How many night students? ");
nightStudents = new NightStudent[sc.nextInt()];
}
public static void enterDataDs() {
for (int i = 0; i < dayStudents.length; i++) {
dayStudents[i] = new Student();
dayStudents[i].getInfo();
}
}
public static void enterDataNs() {
for (int i = 0; i < nightStudents.length; i++) {
nightStudents[i] = new NightStudent();
nightStudents[i].getInfo();
}
}
public static void showDataDs() {
dayStudents[0].showTitle();
for (Student ds : dayStudents) {
ds.showInfo();
}
System.out.println("\n------------------------------------");
}
public static void showDataNs() {
nightStudents[0].showTitle();
for (NightStudent ns : nightStudents) {
ns.showInfo();
}
System.out.println("\n------------------------------------");
}
public static int menu() {
System.out.println("1. Enter daily students data.");
System.out.println("2. Report daily students data.");
System.out.println("3. Enter night students data.");
System.out.println("4. Report night students data");
System.out.println("0. Exit");
System.out.println("Choose: ");
return sc.nextInt();
}
}