0% found this document useful (0 votes)
50 views3 pages

SRC

The document is a Java program that processes student data from an input file and writes results to an output file. It includes a class named Q1 with methods for setting file paths, reading input, executing commands based on input, and printing results. The program is structured with fixed parts that should not be edited and sections where students can add their own code for input and output handling.

Uploaded by

Trạng Nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views3 pages

SRC

The document is a Java program that processes student data from an input file and writes results to an output file. It includes a class named Q1 with methods for setting file paths, reading input, executing commands based on input, and printing results. The program is structured with fixed parts that should not be edited and sections where students can add their own code for input and output handling.

Uploaded by

Trạng Nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

/*

* To change this license header, choose License Headers in Project


Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package q1;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import static java.lang.Compiler.command;
import java.util.ArrayList;
import java.util.Scanner;

public class Q1 {
//Change the name of input and output file based on practical paper
String inputFile = "input.txt";
String outputFile = "output.txt";

//--VARIABLES - @STUDENT: DECLARE YOUR VARIABLES HERE:


ArrayList<SinhVien> sv = new ArrayList<>();
ArrayList<Khoa> k = new ArrayList<>();
StringBuilder result = new StringBuilder();

//--FIXED PART - DO NOT EDIT ANY THINGS HERE--


//--START FIXED PART--------------------------
String fi, fo;

/**
* Set input and output file for automatic rating
* @param args path of input file and path of output file
*/
public void setFile (String[] args){
fi = args.length>=2? args[0]: inputFile;
fo = args.length>=2? args[1]: outputFile;
}

/**
* Reads data from input file
*/
public void read(){
try (Scanner sc = new Scanner(new File(fi))){
//--END FIXED PART----------------------------

//INPUT - @STUDENT: ADD YOUR CODE FOR INPUT HERE:


int T = sc.nextInt();
sc.nextLine();
for (int i = 0; i < T; i++) {
String line = sc.nextLine();
command(line);
}
//--FIXED PART - DO NOT EDIT ANY THINGS HERE--
//--START FIXED PART--------------------------
sc.close();
}catch(FileNotFoundException ex){
System.out.println("Input Exception # " + ex);
}
}
//--END FIXED PART----------------------------

//ALGORITHM - @STUDENT: ADD YOUROWN METHODS HERE (IF NEED):


private void command(String line) {
String[] tach = line.split(" ");
switch (tach[0]) {
case "SV":
}
}

//--FIXED PART - DO NOT EDIT ANY THINGS HERE--


//--START FIXED PART--------------------------
/**
* Main algorithm
*/
public void solve(){
//--END FIXED PART----------------------------

//ALGORITHM - @STUDENT: ADD YOUR CODE HERE:

//--FIXED PART - DO NOT EDIT ANY THINGS HERE--


//--START FIXED PART--------------------------
}

/**
* Write result into output file
*/
public void printResult(){
try{
FileWriter fw = new FileWriter(fo);
//--END FIXED PART----------------------------

//OUTPUT - @STUDENT: ADD YOUR CODE FOR OUTPUT HERE:


fw.write(result.toString());

//--FIXED PART - DO NOT EDIT ANY THINGS HERE--


//--START FIXED PART--------------------------
fw.flush();
fw.close();
}catch (IOException ex){
System.out.println("Output Exception # " + ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Q1 q = new Q1();
q.setFile(args);
q.read();
q.solve();
q.printResult();
}
//--END FIXED PART----------------------------
}

You might also like