Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Coded By Alvin Tabontabon
- // BSIT
- import java.io.*;
- import java.util.*;
- public class cashieringInJava {
- public static BufferedReader br = new BufferedReader(new InputStreamReader(
- System.in));
- public static void main(String[] args) throws IOException {
- try {
- File myFile = new File("employee.txt");
- if (myFile.exists()) {
- getData();
- dtr();
- } else
- System.out.println("Not Found!");
- } catch (NullPointerException npe) {
- System.out.print("");
- }
- }
- public static void dtr() throws IOException {
- File myDTR = new File("dtr.txt");
- System.out.println();
- if (myDTR.exists()) {
- String[] day = { "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY",
- "FRIDAY" };
- BufferedWriter bw = new BufferedWriter(new FileWriter(myDTR));
- for (int i = 0; i < day.length; i++) {
- System.out.print("Enter time-in for " + day[i] + ": ");
- bw.write(day[i] + " " + br.readLine());
- System.out.print("Enter time-out for " + day[i] + ": ");
- bw.write(" TO " + br.readLine());
- bw.newLine();
- System.out.println();
- }
- bw.close();
- } else
- System.out.println("File Not Found!");
- }
- public static void getData() throws IOException {
- System.out.print("Enter employee code: ");
- String empCod = br.readLine();
- Vector<String> v = new Vector<String>();
- int x = 0, a = 0;
- String[] temp = new String[3];
- FileInputStream fis = new FileInputStream("employee.txt");
- InputStreamReader isr = new InputStreamReader(fis);
- BufferedReader br = new BufferedReader(isr);
- String str = "";
- String strData;
- try {
- while (str != null) {
- str = br.readLine();
- StringTokenizer st = new StringTokenizer(str, ",");
- while (st.hasMoreTokens()) {
- strData = st.nextToken();
- v.add(x, strData);
- if (v.elementAt(x).equals(empCod)) {
- while (strData != null) {
- temp[a] = strData;
- a++;
- strData = st.nextToken();
- if (a == 2) {
- System.out.println("Employee Code: " + temp[0]);
- System.out.println("Employee Name: " + temp[1]);
- System.out.println("Salary Level: " + strData);
- }
- }
- }
- }
- x += 1;
- if (x == 4) {
- System.out.println("Record Not Found!");
- }
- }
- } catch (NoSuchElementException nsee) {
- System.out.print("");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement