import javabook.*;

/*
 * Introduction to OOP with Java 2nd Edition, McGraw-Hill
 *	
 *  PayScaleTable
 *   
 *  A sample program to illustrate the 2-D array operations
 *  discussed in Section9.7.
 *  
 * @author Dr. Caffeine
 *
 */
class PayScaleTable 
{
    public static void main (String[] args)
    {
        MainWindow  mainWindow;
        OutputBox 	outputBox;
        InputBox    inputBox;  
        
        mainWindow = new MainWindow("Program Title Here");
        outputBox  = new OutputBox( mainWindow );
        inputBox   = new InputBox ( mainWindow );
                
        mainWindow.setVisible( true ); 
        outputBox.setVisible( true );
        
        //Declare and initialize the pay scale table
        
        double[][] payScaleTable 
                        = {  {10.50, 12.00, 14.50, 16.75, 18.00},
                             {20.50, 22.25, 24.00, 26.25, 28.00},
                             {34.00, 36.50, 38.00, 40.35, 43.00},
                             {50.00, 60.00, 70.00, 80.00, 99.99}  };        
        
        
        //Find the average pay of Level 2 employees
        double sum = 0.0, average;
        
        for (int j = 0; j < 5; j++) {
            sum += payScaleTable[2][j];
        }
        
        average = sum / 5;
        
        outputBox.printLine(" Average of Level 2 Employees: " + average );
        outputBox.skipLine( 2 );
        
        //Display the pay difference at each grade level
        double difference;
        
        for (int i = 0; i < 4; i++) {
            difference = payScaleTable[i][4] - payScaleTable[i][0];
            outputBox.printLine("Pay difference at Grade Level " +
                                     i + " is " + difference);
        }
            
        //Print out the pay scale table 
        outputBox.skipLine( 2 );
        
        for (int i = 0; i < payScaleTable.length; i++) {
            
            for (int j = 0; j < payScaleTable[i].length; j++) {
                
                outputBox.print( payScaleTable[i][j] + "    " );
            }
            
            outputBox.skipLine( 1 );
        }
        
        //Increase the pay by 1.50 for every level/step
        //and display the resulting table
        outputBox.skipLine( 2 );
        
        for (int i = 0; i < payScaleTable.length; i++) {
            
            for (int j = 0; j < payScaleTable[i].length; j++) {
                
                payScaleTable[i][j] += 1.50;
               
                outputBox.print( payScaleTable[i][j] + "    " );
            }
            
            outputBox.skipLine( 1 );
        }
    
            
    }
    
}