In: Computer Science
Part 1 (20%)
Implement a class with a main method. Using an enhanced for loop, display each element of this array:
String[] names = {"alice", "bob", "carla", "dennis", "earl", "felicia"};
Part 2 (30%)
In a new class, implement two methods that will each calculate and
return the average of an array of numeric values passed into it.
Constraints:
Implement a new class demonstrating your methods in action. Call your methods at least twice each with arrays of different sizes each time.
Part 3 (50%)
The Valencia Ice Cream Shoppe pays its summer employees bonuses
based on two factors: the number of weeks worked over the summer,
and the number of positive customer reviews. The table below shows
the bonuses based on these two factors.
| 
 Positive Reviews (right) Weeks Worked (down)  | 
0 | 1 | 2 | 3 | 4 or more | 
| 0 | 25 | 45 | 80 | 110 | 150 | 
| 1 | 50 | 60 | 90 | 120 | 180 | 
| 2 | 100 | 125 | 160 | 210 | 265 | 
| 3 | 160 | 190 | 225 | 275 | 340 | 
| 4 | 230 | 270 | 325 | 385 | 450 | 
| 5 | 300 | 360 | 420 | 480 | 600 | 
| 6 or more | 425 | 500 | 600 | 700 | 875 | 
Examples:
Write an application that:
Please submit:
(1) all source code (.java files)
(2) screenshots showing all programs in action (image files)
Question 1
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication23;
import java.util.Random;
import java.util.Scanner;
/**
 *
 * @author haptop laptop
 */
public class JavaApplication23 {
    /**
     * @param args the command line arguments
     */
    
  
    public static void main(String[] args) {
        // TODO code application logic here
        String [] names={"alice","bob","carla","dennis","earl","felicia"};
                for(int i=0;i<names.length;i++)
                System.out.print(names[i]+" ");
                
       
       
    }
    
    
}
Question 2
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication23;
import java.util.Random;
import java.util.Scanner;
/**
 *
 * @author haptop laptop
 */
class Test{
   
    double findAverage(int [] array)
    {
        int sum=0;
        for(int i=0;i<array.length;i++)
        {
            sum+=array[i];
            
        }
       double average=(sum*1.0)/(array.length);
       return Math.round(average*100.0)/100.0;//to return up to 2 decimal
       
    }
    double findAverage(double [] array)
    {
        double sum=0;
        for(int i=0;i<array.length;i++)
        {
            sum+=array[i];
        }
       double average=(sum*1.0)/(array.length);
       return Math.round(average*100.0)/100.0;//to return up to 2 decimal
       
        
    }
    
}
public class JavaApplication23 {
    /**
     * @param args the command line arguments
     */
    
  
    public static void main(String[] args) {
        // TODO code application logic here
        int[] myArray1={1,2,3,4,5,6,6};
        double[] myArray2={1.0,2.1,3.2,4.3,5.3,6.2};
        Test t1=new Test();
        System.out.println("Average of first array"+t1.findAverage(myArray1));
        System.out.println("Average of second array"+t1.findAverage(myArray2));
        
       
    }
    
    
}

Question 3
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication23;
import java.util.Random;
import java.util.Scanner;
/**
 *
 * @author haptop laptop
 */
public class JavaApplication23 {
    /**
     * @param args the command line arguments
     */
    
  
    public static void main(String[] args) {
        // TODO code application logic here
        int bonuse[][]={{25,45,80,110,150},{50,60,90,120,180},{100,125,160,210,265},{160,190,225,275,340},{230,270,325,385,450},{300,360,420,480,600},{425,500,600,700,875}};
           Scanner sc=new Scanner(System.in);
            System.out.print("Enter number of employeees? ");
            int n=sc.nextInt();
            int sum=0;
            while(n>0)
            {
                System.out.print("Enter number of week worked and review ");
                int row=sc.nextInt();
                int col=sc.nextInt();
                if(col>=4)
                {
                    col=4;
                }
                if(row>=6)
                    row=6;
                System.out.println("Employee will get $"+bonuse[row][col]);
                
                sum+=bonuse[row][col];
                
                n--;
            }
            System.out.println("Total bonus $"+sum);
        }
       
    }
    
    
