// 0) (10 points) ADD YOUR FIRST AND LAST NAME HERE:

import java.util.Scanner;

// All the remaining questions are stated in the comments below...

public class Main {

    public static void main (String [] args) {

        // 1) (10 points) Insert a statement beneath this comment that
        //    will make this program print your first and last name
        //    to standard output (in this case, the monitor):

        System.out.println("John Doe");

        // 2) (20 points total, 4 each) Your kindly instructor has just
        //    written five equations on the board (if not, please remind
        //    him to do so now). In the space below, write an assigment
        //    statement matching each of these equations. Use the variables
        //    declared below to represent the corresponding symbols in
        //    each equation. Note that you can reuse the same variables
        //    in more than one formula.

        double a = 0, b = 0, c = 0;
        double x = 0, y = 0, z = 0;
        double r = 0, v = 0;

        y = a * x * x + b * x + c;
        z = Math.sqrt (x*x + y*y);
        y = a * b / (c * c);
        v = 4.0 / 3 * Math.PI *r * r * r;
        y = a * Math.exp(-b * x);

        // 3) (10 points) Write a statement below that declares an integer
        //    variable N, and attempts to get its value from the first
        //    command-line argument for this program:

        int N = Integer.parseInt(args[0]);

        // 4) (10 points) Write statements below that will print one of
        //    the following messages, depending on the value of N:
        //
        //        "N is even" if N is even
        //        "N is odd"  if N is odd

        if (N % 2 == 0) {
            System.out.println("N is even");
        }
        else {
            System.out.println("N is odd");            
        }

        // 5) (10 points) For this question, assume (without checking)
        //    that N stores a positive value. Insert statements below
        //    that compute and print the sum of all the positive
        //    integers from 1 through N (including both 1 and N):

        int sum = 0;
        for (int i = 1; i <= N; i++) {
            sum = sum + i;
        }

        System.out.println("sum = " + sum);

        // 6) (10 points) Insert statements below that compute and print
        //    the sum of N randomly chosen integers ranging from 1 through
        //    10 (including both 1 and 10):
        
        sum = 0;
        for (int i = 1; i <= N; i++) {
            int n = 1 + (int) (10*Math.random());
            sum += n;
        }
        System.out.println("sum = " + sum);

        // 7) (10 points) Insert one or more statements below that declare
        //    and create an array named "vector", which has space for 10
        //    real values (use type double). Arrange matters so that all
        //    the array components are initialized to 0.

        double [] vector = new double [10];
        for (int i = 0; i < vector.length; i++) {
            vector[i] = 0.0;
        }
        // 8) (10 points) Insert statments below that
        //
        //      a) read 10 real numbers from the keyboard into the array
        //         you created above;

        for (int i = 0; i < vector.length; i++) {
            vector[i] = StdIn.readDouble();
        }
/*
        Scanner scanner = new Scanner(System.in);

        for (int i = 0; i < vector.length; i++) {
            vector[i] = scanner.nextDouble();
        }
*/
        //      b) compute the average of all the array components;
        double sum2 = 0.0;

        for (int i = 0; i < vector.length; i++) {
            sum2 += vector[i];
        }
        double avg = sum2 / vector.length;
        System.out.println("avg = " + avg);

        //      c) print both the index and value of each component
        //         that exceeds the array average.

        for (int i = 0; i < vector.length; i++) {
            if (vector[i] > avg) {
                System.out.println(i + " " + vector[i]);
            }
        }

        //    Note: to read the numbers, use either the java.util.Scanner
        //    class discussed in your lectures, or the textbook's StdIn
        //    library class. The StdIn class has been already been downloaded
        //    from the Booksite in case you prefer that option.
    }
}
