American Young Coder (AYC)

• This event has passed.

# 7 PM – Intro To Java – Roland

## March 27 @ 7:00 pm - 8:00 pm

##### Today We Did
1. Learned about &&, ||, !=, and !
1. && = And
2. || = Or
3. != –> not equals (primitives)
4. ! –> negate
2. .equals() and .equalsIgnoreCase()
3. Lists in Java
1. List<String> names = new ArrayList<>();
3. Getting from a list: names.get(0);
4. Modifying a list: names.set(0, “new_name”);
5. Inserting into a list: names.add(1, “second_name”);
6. Size of list: names.size();
7. Looping through a list: for (String n: names) {…}
##### Homework
1. Create a new Java file March27_AndOrListHW.java
2. Complete the following exercises:
1. Write a new Java program that will ask the user for the grade they got on their exam (which is an integer)
1. If the number is between 60 to 70, print “Your grade is D”. You have to use AND (&&).
2. If the number is between 70 to 80, print “Your grade is C”. You have to use AND (&&).
3. If the number is between 80 to 90, print “Your grade is B”. You have to use AND (&&).
4. If the number is between 90 to 99, print “Your grade is A”. You have to use AND (&&)
5. If the number is equal to 100, print “Your grade is A+, good job”.
2. Write a new Java program that will create a List of String and add all of these colors: red, green, blue, purple, yellow, orange. ([“red”, “green”, “blue”, “purple”, “yellow”, “orange”])
3. Use for loop to go through each color inside the above list and print all colors to the shell.
1. If the color is “blue”, print “blue is my favorite color”. If the color is “yellow”, print “I don’t like yellow color.
2. For everything else, just print the color name.
3. The result should be like below
4. red
green
Blue is my favorite color
purple
I don't like yellow
orange