/* This program performs a yearly update on a salary file. It increments the number of years with the conpany by one and gives a raise of $100 dollars if the employee has worked with the company for more than 10 years, and $50 otherwise. The output is sent to a text file, and also shown on the screen. */ import java.io.*; class SalaryUpdate { public static void main(String[] args) throws IOException { final int RAISE1 = 100; final int RAISE2 = 50; BufferedReader stdin; stdin = new BufferedReader (new InputStreamReader (System.in)); String inputpath, outputpath; System.out.print ("Enter the pathname of the input file: "); System.out.flush (); inputpath = stdin.readLine(); System.out.print ("Enter the pathname of the output file: "); System.out.flush (); outputpath = stdin.readLine(); FileReader textFile1; textFile1 = new FileReader(inputpath); BufferedReader inputFile; inputFile = new BufferedReader (textFile1); FileWriter textFile2; textFile2 = new FileWriter(outputpath); PrintWriter outputFile; outputFile = new PrintWriter(textFile2); String name; double salary; int years; /* Read the first item of the first data group from the text file */ name = (inputFile.readLine()); /* The last data item in the text file is "nomore" to mark the end of the file. */ while (!(name.equals("nomore"))) { salary = new Double (inputFile.readLine()).doubleValue(); years = Integer.parseInt(inputFile.readLine()); years++; if (years > 10) salary = salary + RAISE1; else salary = salary + RAISE2; /* Save the results in the output file. */ outputFile.println (name + "\t" + salary + "\t" + years); /* Show results on the screen. */ System.out.println (name + "\t" + salary + "\t" + years); /* Read the next name from the text file. */ name = (inputFile.readLine()); } inputFile.close(); outputFile.close(); } }