/** PhLabeler reads/labels pH values using file I/O.
 *  @author Joel Adams, for Alice+Java.
 *
 */

/** PhLabeler.java reads/labels pH values using file I/O.
 */
import java.util.Scanner;
import java.io.*;         // File, PrintWriter, ...

public class PhLabeler {
	public static void main(String[] args) {		
		try {
	        // build Scanner for input file
	        System.out.print("Enter name of the input file: ");
	        Scanner kbd = new Scanner(System.in);
	        String inFileName = kbd.nextLine();
	        File inFile = new File(inFileName);
	        Scanner fin = new Scanner(inFile);
	        // build PrintWriter for output file
	        System.out.print("Enter name of the output file: ");
	        String outFileName = kbd.nextLine();
	        File outFile = new File(outFileName);
	        PrintWriter fout = new PrintWriter(outFile);
	        // read from input file, writing results to output file
	        while ( fin.hasNextDouble() ) {
	           double phValue = fin.nextDouble();
	           PH pH = new PH(phValue); 
	           fout.println(phValue + " --> " + pH.label() );
	        }
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

