/******************************************************************
 * Program: MenuCalculator
 *
 * Programmer: Tyler Johnson
 *
 * Due Date: N/A

 *
 * COMP 110-001        Instructor: Tyler Johnson
 *
 * Description: This program asks the user to input two floating-point
 *				numbers.  It then allows the user to perform one of four
 *				operations on the numbers selected by the user.
 *  
 *				Options: Add the two numbers, subtract the two numbers,
 *						 multiply the two numbers, divide the two numbers
 *
 * Input: Two floating point numbers and an option
 *
 * Output: The result of performing the selected option on the two numbers
 *
 ******************************************************************/

import java.util.Scanner;

public class MenuCalculatorLoop  {
	
	public static void main(String[] args)  {
	
		double a = 0, b = 0;
		
		Scanner keyboard = new Scanner(System.in);

		//Ask user to input two numbers		
		System.out.println("Hello.  Please enter two numbers on a line separated by a space.");
		
		a = keyboard.nextDouble();
		b = keyboard.nextDouble();
		
		boolean valid = false;
	
		while(!valid)  {
		
			//valid == false
			valid = true; //assuming the user enters valid input
			
			//Provide the user with a list of the options	
			System.out.println("Thank you. Please select one of these options");
			System.out.println("1 - Add the two numbers");
			System.out.println("2 - Subtract the two numbers");
			System.out.println("3 - Multiply the two numbers");
			System.out.println("4 - Divide the two numbers");
			System.out.print("Option: ");
			
			int option;
			
			option = keyboard.nextInt();
			
			//Perform the operation selected by the user
			//Output the result
			
			System.out.print("The result is: ");
			
			switch(option)  {
			
				case 1:
					System.out.println(a+b);
					break;
				case 2:
					System.out.println(a-b);
					break;
				case 3:
					System.out.println(a*b);
					break;
				case 4:
					System.out.println(a/b);
					break;
				default:
					valid = false; //invalid input
					System.out.println("Error - Invalid Input");
					break;
			}
		}
	}
}