/** PhLabeler reads a Ph value, and indicates whether it is
 *   acidic, neutral, or basic.
 *  @author Joel Adams
 *
 */
import java.util.Scanner;

public class PhLabeler {
	public static void main(String[] args) {
//		testPHLabel();
		Scanner kbd = new Scanner(System.in);
		boolean done = false;
		while (!done) {
			System.out.print("Enter a pH value (-1 to quit): ");
			double phValue = kbd.nextDouble();
			if (phValue < PH.MIN) {
				done = true;
			} else {
				PH pH = new PH(phValue);
				System.out.println("--> " + pH.label() );
			}
		}
	}

	public static void testPHLabel() {
		System.out.print("Testing phLabel()... ");
		String str = new PH(-0.01).label();
		assert str.equals("error");
		str = new PH(0.0).label();
		assert str.equals("acidic");
		str = new PH(6.99).label();
		assert str.equals("acidic");
		str = new PH(7.0).label();
		assert str.equals("neutral");
		str = new PH(7.01).label();
		assert str.equals("alkaline");
		str = new PH(14.0).label();
		assert str.equals("alkaline");
		str = new PH(14.1).label();
		assert str.equals("error");
		System.out.println(" Passed!");
	}
}
