import java.util.Scanner;

/* A simple complex number calculator.  Non-object-oriented. */
public class SimpleComplex{

  // Driver of the program, a shiny new simple complex calculator!
  public static void main(String[] args){
    
    // Instantiate an object of the Scanner class for keyboard input
    Scanner keyboard = new Scanner(System.in);
    
    // Print out a single menu of operations

    //----- Write your code below -----
    //        to print the menu
    
    
    //----- Write your code above -----
    //      for printing the menu
    
      
    // Looping continues until the user chooses to quit the calculator
    boolean flag = true;
    while (flag) { 
      
      // Collect input from the user for this iteration.  Remember* that,
      // unlike Matlab, the operations of prompting and collecting are
      // seperated.
      
      // Prompt
      System.out.print("\n\nOperation?  :  ");
      // Collect.  next() reads the next input as a String.  We have not 
      // yet discussed Strings yet.
      String operation = keyboard.next(); 

      if (isBadOperation(operation)){ //Halt?
        System.out.println("You chose to stop or gave a bad operation.  Goodbye.");
        flag = false;
      }
      else { //Keep processing.
        // Echo user choice and proceed.
        System.out.println("Operation is " + operation);
        
        // Prompt for and collect the data needed for the operation.
        // Unary operations need one complex number while binary 
        // operations need two complex numbers.

        //----- Write your code below -----
        //        to prompt for data
    
    
        //----- Write your code above -----
        //        to prompt for data
    
        
        // Perform the operation (add, divide, magnitude, or angle)

        //----- Write your code below -----
        //    to perform the operation

        
        // An example is given for the add operation below.  You need
        // to change it to work with the user input and to deal with the 
        // other operations.
        if (operation.equalsIgnoreCase("add")){ //addition
            add(2.1, 1, -4, 2);
        }

        // Above we demonstrate the use of instance method equalsIgnoreCase 
        // of the String class.  It returns a boolean value answering the 
        // question, 'Ignoring case, does the String operation and match "add"
        // exactly?'  You will learn more about instance methods later.

        
         //----- Write your code above -----
        //  for performing the operation
    
         
      } //end else--valid operations
    } //end while
  } //main method
  

  // Print a complex number as follows:  ( realPart + imagPart i )
  public static void print(double realPart, double imagPart){

    //---- Implement this method ----
  
  }
  
  
  // Calculate and print  (x+yi) + (u+vi)
  public static void add(double x, double y, double u, double v){
    print(x,y);
    System.out.print(" + ");
    print(u,v);
    System.out.print(" = ");
    print(x+u, y+v);
  }
  
  
  // Calculate and print  (x+yi) / (u+vi)
  public static void div(double x, double y, double u, double v){

    //---- Implement this method ----
  
  }
  
  
  // Calculate and print the magnitude of  (x+yi)
  public static void mag(double x, double y){

    //---- Implement this method ----
  
  }
  
  
  // Calculate and print the angle of  (x+yi)
  public static void ang(double x, double y){

    //---- Implement this method ----
  
  }

  
  // ={op denotes a binary operation, true or false}
  public static boolean isBinaryOp(String op){
    // Returns true if op is a binary operation and false otherwise
    return op.equalsIgnoreCase("add") || op.equalsIgnoreCase("div");
  }
  
  // ={op is not a recognized operation in the calculator, true or false}
  public static boolean isBadOperation(String op){
    boolean badOp = !(op.equalsIgnoreCase("add") ||
                      op.equalsIgnoreCase("div") ||
                      op.equalsIgnoreCase("mag") ||
                      op.equalsIgnoreCase("ang"));
    return badOp;
  }
  
} //class SimpleComplex 


// * - In the lab we saw this in the lab of 3-15-06.