-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourseGenerator.java
More file actions
46 lines (37 loc) · 1.61 KB
/
CourseGenerator.java
File metadata and controls
46 lines (37 loc) · 1.61 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
package coursegenerator;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class CourseGenerator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in); //scanner for user input
System.out.println("Please enter the file name: ");
String fileName = scanner.nextLine();
try
{
Scanner read = new Scanner(new File(fileName)); //scanner for file
int professors = read.nextInt(); //read in how many prof
int submitted = read.nextInt(); //read in how many prefered
int recieve = read.nextInt(); //read in how many prof will recieve
int[][] arr = new int[professors][submitted];
for (int i = 0; i < professors; i++)
{
read.nextInt(); //read which professor we are on
read.next(":"); //read the colon separating prof and submitted
for (int j = 0; j < submitted; j++)
{
arr[i][j] = read.nextInt();
}
}
Generate generator = new Generate(arr, professors, submitted, recieve);
long startTime = System.currentTimeMillis();
generator.solve();
long endTime = System.currentTimeMillis();
System.out.println("Duration: " + (endTime - startTime) + " milliseconds");
}
catch (IOException e) //catch IO exception from the file input
{
System.out.println(e);
}
}
}