N@TM

  • Presented on our database quiz and api
  • Great experience talking with students and parents
  • Looked at studio arts and AP CSP projects
    • Tested the Team Berries Dictionary

image

Recap of units

HW

Unit 1 HW

// java style to import library
import java.util.Scanner;

// class must alway have 1st letter as uppercase, CamelCase is Java Class convention
public class ScanPrimitives {
    public static void main(String[] args) {    
        Scanner myObj = new Scanner(System.in);  // Create a Scanner object
        System.out.println("Is the final in a seperate category? True to False");

        boolean tof = myObj.nextBoolean();  // Read user input
        System.out.println("Final in a seperate category is " + tof);  // Output user input

        if (tof) {
            System.out.println("What is your current grade rn?");
            double grade = myObj.nextDouble();
            System.out.println(grade);

            System.out.println("What is % of grade that is final?");
            double percent = myObj.nextDouble();
            System.out.println(percent + "%");

            System.out.println("What is your desired grade?");
            double desired = myObj.nextDouble();
            System.out.println(desired);

            double output = (desired - (grade * ((100-percent)/100)))/(percent/100);
            System.out.println("You need a " + output + " on your final");
        }
        else {
            System.out.println("What is your current grade rn?");
            double grade = myObj.nextDouble();
            System.out.println(grade);

            System.out.println("What is the % of grade that is test category?");
            double percent = myObj.nextDouble();
            System.out.println(percent + "%");

            System.out.println("What is current % in tests category?");
            double currentpercent = myObj.nextDouble();
            System.out.println(currentpercent + "%");

            System.out.println("What is the current amount of points in the test category?");
            int currentpts = myObj.nextInt();
            System.out.println(currentpts);

            System.out.println("How many pts is the final?");
            int pts = myObj.nextInt();
            System.out.println(pts);

            System.out.println("What is your desired grade?");
            double desired = myObj.nextDouble();
            System.out.println(desired);

            // double output = (desired - ((grade * currentpercent)*((100 - percent)  / 100)))/((currentpts + pts)/(percent / 100))- currentpts;
            double output = ((desired - grade+currentpercent)*(currentpts+pts)-currentpts*currentpercent)/100;
            // double output = 
            // desired = percent * 
            // current grade = 
            System.out.println("You need " + output + " pts on your final");
        }
    
    
}

}
ScanPrimitives.main(null);
Is the final in a seperate category? True to False
Final in a seperate category is true
What is your current grade rn?
90.0
What is % of grade that is final?
25.0%
What is your desired grade?
93.0
You need a 102.0 on your final

Unit 2

public int scoreGuess(String guess)
{
    int count = 0;
    for (int i = 0; i <= secret.length() - guess.length(); i++)
    {
        if (secret.substring(i, i + guess.length()).equals(guess))
        {
            count++;
        }
    }
    return count * guess.length();
}
public String findBetterGuess(String guess1, String guess2) {
    if (scoreGuess(guess1) > scoreGuess(guess2)) {
        return guess1;
    }
    if (scoreGuess(guess2) > scoreGuess(guess1)) {
        return guess2;
    }
    if (guess1.compareTo(guess2) > 0) {
        return guess1;
    } else {
        return guess2; 
    }

}

Unit 4

public class CaesarCipher {

    String[] letters = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
    String[] capitalLetters = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
    
    static String message1 = "Kfzb gly!"; 
    static String message2 = "zlab zlab zlab";
    static String message3 = "prmbozxifcoxdfifpqfzbumfxifalzflrp";

    String letterIndividual = "";


    public CaesarCipher(String msg) {
        for (int i = 0; i < msg.length(); i++) {
            letterIndividual = msg.substring(i, i+1);


            if (letterIndividual.equals(" ")) {
                System.out.print(" "); 
            }

            if (letterIndividual.equals("!")) {
                System.out.print("!"); 
            }

            for (int j = 0; j < letters.length; j++) {
                if (letterIndividual.equals(letters[j])) {
                    System.out.print(letters[(j+3)%26]); 
                }

                if (letterIndividual.equals(capitalLetters[j])) {
                    System.out.print(capitalLetters[(j+3)%26]); 
                }
                
                
            }
        }
        System.out.println(""); 
    }

    public static void main(String[] args) {
        CaesarCipher decode = new CaesarCipher(message1); 
        CaesarCipher decode2 = new CaesarCipher(message2); 
        CaesarCipher decode3 = new CaesarCipher(message3); 

    }
}
CaesarCipher.main(null)
Nice job!
code code code
supercalifragilisticexpialidocious

Unit 5

  • did the form mc with Lily
public class StepTracker {
    private int lowerBound;
    private int steps;
    private int totalDays;
    private int activeDays;

    public StepTracker(int minSteps) {
        lowerBound = minSteps;
        steps = 0;
        totalDays = 0;
        activeDays = 0;
    }

    public void addDailySteps(int newSteps) {
        steps += newSteps;
        totalDays += 1;
        if (newSteps >= lowerBound) {
            activeDays += 1;
        }
    }

    public int activeDays(){
        return activeDays;
    }

    public double averageSteps() {
        if (totalDays == 0) {
            return (double) totalDays;
        }
        else {
            return (double) steps / totalDays;
        }
    }

    public static void main(String[] args){

        StepTracker tr = new StepTracker(10000);
        System.out.println(tr.activeDays());
        System.out.println(tr.averageSteps());
        tr.addDailySteps(9000);
        System.out.println(tr.averageSteps());
        tr.addDailySteps(23000);
        System.out.println(tr.activeDays());
    }
}
StepTracker.main(null);
0
0.0
9000.0
1

Unit 6

Not too sure what I was thinking. names[n] would be incorrect in a foreach loop

public void addMembers(String[] names, int gradYear) {
    for (String n : names) {
        memberInfo member = new MemberInfo(names[n], gradYear, true);
        memberList.add(member);
    }
    
}

Revised

public void addMembers(String[] names, int gradYear) {
    for (String n : names) {
        memberInfo member = new MemberInfo(n, gradYear, true);
        memberList.add(member);
    }
    
}

CB corrections

Score

image

#15

  • misread the question. thought it wanted the array to be sorted in decreasing order

#21

  • We are trying to find the closest number so subtracting the row number will not make any sense. Not too sure why I chose E

#22

  • Need to use typecasting to let the compiler know that the object stored in the books array at this index is actually an AudioBook object. Didn't realize that there would be no compile error because igt will run the lengt() method in Audiobook because books[0] is in it

#33

  • ahhhh brain fart. somehow I thought that because sum would be eventually false, the loop will break. It will only break if they are both false, which will never happen because k will be constant.

#40

  • didn't see that it kept on calling whatsitdo