// ---
// jupyter:
//   jupytext:
//     text_representation:
//       extension: .java
//       format_name: light
//       format_version: '1.5'
//       jupytext_version: 1.14.4
//   kernelspec:
//     display_name: Java
//     language: java
//     name: java
// ---

// # Lab Three
// ---
//
// For this lab we're going to be making and using a bunch of functions. 
//
// Our Goals are:
// - Switch Case
// - Looping
// - Making our own functions
// - Combining functions
// - Structuring solutions

// Give me an example of you using switch case.
int favGen = 5;
switch (favGen){
    case 1:
        System.out.println("Gen 1 is completly broken");
        break;
    case 2:
        System.out.println("Gen 2 is still broken but less so");
        break;
    case 3:
        System.out.println("Gen 3 was amazing but too much water");
        break;
    case 4:
        System.out.println("Gen 4 was top teir, just super slow");
        break;
    case 5:
        System.out.println("Gen 5 had the best story, but was too linear");
        break;    
}

// Give me an example of you using a for loop
for(int i = 1; i <=8; i++){
    System.out.println(i);
}

// Give me an example of you using a for each loop
String[] favStarters = {"Rowlet","Cyndaquil","Frokie"};
for(String mon : favStarters){
    System.out.println(mon);
}

// Give me an example of you using a while loop
int i = 0;
while(i<10){
    System.out.println(i);
    i++;
}

// +
// I want you to write a function that will take in a number and raise it to the power given. 

// For example if given the numbers 2 and 3. The math that the function should do is 2^3 and should print out or return 8. Print the output.
System.out.println(Math.pow(2,3));

// +
// I want you to write a function that will take in a list and see how many times a given number is in the list. 

// For example if the array given is [2,3,5,2,3,6,7,8,2] and the number given is 2 the function should print out or return 3. Print the output.
int[] array = {2,3,5,2,3,6,7,8,2};
int search(int[] input, int item){
    int x = 0;
    for(int num:input){
        if (num==item){
            System.out.println(item);
            x++;
        }
    }
    System.out.println("total ammount:");
    return x;
}
System.out.println(search(array,2));

// +
// Give me a function that gives the answer to the pythagorean theorem. 
// I'd like you to reuse the exponent function from above as well as the functions below to make your function.

// If you don't remember the pythagorean theorem the formula is (a^2 + b^2 = c^2). Given a and b as parameters i'd like you to return c. 
// If this doesn't make sense look up `Pythagorean Theorem Formula` on google.

int addition(int a, int b) {
    int answer = a + b;
    return answer;
}

int division(int a, int b) {
    int answer = a / b;
    return answer;
}
//also written as sqrt(a^2+b^2)
double pythagorean(double x, double y){
    x = Math.pow(x,2);
    y = Math.pow(y,2);
    double added = x+y;
    Math.sqrt(added);
    return added;
}
System.out.println(pythagorean(3,7));



StarcoderdataJupyterScriptsDedupFiltered