/*Author: Pranav Yanambakkam

Contest 2 Programming Problem

Date: 02/15/2013*/

 

import java.util.Scanner;

 

 

public class Contest2{

      public static void main(String[] args)

      {    

            int intLineNumber = 1;

            while(intLineNumber < 6) //execute piece of code five times

            {

                  System.out.println("Enter Line " + intLineNumber + " : ");

                  Scanner in = new Scanner(System.in);

           

                  String strOperator = in.next();

                  String strOperand = in.next(); //initializing variables

           

                  System.out.println("Operator : " + strOperator);

                  System.out.println("Operand : " + strOperand); //displaying operators and operands

           

                  if(strOperator.equals("DIVIDE,"))

                  {

                        String strOP1 = strOperand.substring(0,4); //splitting strOperand

                        String strOP1Output = strOP1 + strOP1;

                 

                        String strOP2 = strOperand.substring(4,8);

                        String strOP2Output = strOP2 + strOP2;

                 

                        System.out.println(strOP1Output + " and " + strOP2Output); //displaying results

                 

                  }

                  else if(strOperator.equals("ADD0,"))

                  {

                        System.out.println(strOperand); //telling what to do if condition is true

                  }

                  else if(strOperator.equals("ADD1,"))

                  {

                        String strOPOutput = strOperand.substring(0,1) + strOperand.substring(0,1) + strOperand.substring(1,7);

                       

                        System.out.println(strOPOutput);

                  }

                  else if(strOperator.equals("ADD2,"))

                  {

                        String strOPOutput = strOperand.substring(0,2) + strOperand.substring(0,2) + strOperand.substring(2,6);

                       

                        System.out.println(strOPOutput);

                  }

                  else if(strOperator.equals("ADD3,"))

                  {

                        String strOPOutput = strOperand.substring(0,3) + strOperand.substring(0,3) + strOperand.substring(3,5);

                       

                        System.out.println(strOPOutput);

                  }

                  else if(strOperator.equals("ADD4,"))

                  {

                        String strOPOutput = strOperand.substring(0,4) + strOperand.substring(0,4);

                       

                        System.out.println(strOPOutput);

                  }

                  else if(strOperator.equals("SUBTRACT0,"))

                  {

                        System.out.println(strOperand); //if the operator is subtract, then execute string subtract operation

                  }

                  else if(strOperator.equals("SUBTRACT1,"))

                  {

                        String strOPOutput = strOperand.substring(1,8) + strOperand.substring(7,8);

                        System.out.println(strOPOutput);

                  }

                  else if(strOperator.equals("SUBTRACT2,"))

                  {

                        String strOPOutput = strOperand.substring(2,8) + strOperand.substring(6,8);

                        System.out.println(strOPOutput);

                  }

                  else if(strOperator.equals("SUBTRACT3,"))

                  {

                        String strOPOutput = strOperand.substring(3,8) + strOperand.substring(5,8);

                        System.out.println(strOPOutput);

                  }

                  else if(strOperator.equals("SUBTRACT4,"))

                  {

                        String strOPOutput = strOperand.substring(4,8) + strOperand.substring(4,8);

                        System.out.println(strOPOutput);

                  }

                  else

                  {

                        System.out.println("Cannot recognize Operator"); //if operator is not recognized, then display error message

                  }

           

                  intLineNumber++; //increment line number

            }

      }

}