Welcome to APCSA
-
Lesson 16 - Exceptions
Classwork
Day 1: In class we created a quick program to play with exceptions. That file should be saved here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/16_exceptions/
Day 2: Directions have been poster here
-
Lesson 16 - Wrapper Classes
Save your work here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/15_wrapper_classes/
-
Lesson 01 - GitHub
GitHub
Read the Git and GitHub documentation provided in the Tools section.
Remember the following GitHub actions
When you work on a machine you never worked before, you should clone your repo:
git clone SSH_GITHUB_LINK
Before you start working on any device, the first command you should run is:
git pull
When you finish your work:
- If you added new files and want to track the files, you must run the following command for each file:
git add FILE_NAME
- Commit the changes:
git commit -a -m "COMMIT_MESSAGE"
- Push the changes o GitHub
git push
-
Lab 07 - Linked List
DUE DATE:Please accept this assignment.
Due Date: Thursday, December 20, 2024 at 23:59 pm.
-
Lab 06 - Sorts
DUE DATE:Please accept this assignment.
Due Date: Thursday, December 12, 2024 at 08:00 am.
-
Lab 05 - Bank Accounts
DUE DATE:Please accept this assignment.
Due Date: Thursday, December 5, 2024 at 08:00 am.
-
Lab 04 - ArrayList Hierarchy
DUE DATE:Please accept this assignment.
Due Date: Monday, November 25, 2024 at 08:00 am.
-
Lab 03 - SuperArray
DUE DATE:Please accept this assignment.
Due Date: Monday, October 28, 2024 at 08:00 am.
-
Lab 02 - Triangle
DUE DATE:Please accept this assignment.
Due Date: Tuesday, October 22, 2024 at 08:00 am.
-
Lab 01 - Random Walker
DUE DATE:Please accept this assignment.
Due Date: Monday, September 30, 2024 at 08:00 am.
-
HW 24 - Review Questions
DUE DATE:Select 5 challenging/tricky questions from previous exams, College Board, or write your own questions. We will go over those questions in class tomorrow.
Save your file here:
.../APCSA_1/apcsa-assignments-YourUsername/homework/24_apcs_review_questions/questions.md
(or txt, docx, pdf) -
HW 23 - Recursion CodingBat
DUE DATE:The following sets of CodingBat problems should be completed:
First Set (We worked on this last Friday)
Second Set (This one, we started in class today)
-
HW 22 - Recursion
DUE DATE:Save your files here:
.../APCSA_1/apcsa-assignments-YourUsername/homework/22_recursion/RecursiveFunctions.java
Exercise 1: Sum digits
Write the solution to the following problem:
Given a non-negative int n, return the sum of its digits recursively (no loops). Do not use strings to solve the problem.
Example: 12945 -> 1 + 2 + 9 + 4 + 5 = 21
Hints:
How to get the digit at the end 12945 => 5?
How to remove the last digit 12945 => 1294?
These questions will guide you in finding the solution:
- What is the base case?
- Which operations can break up the numbers into a single digit and the rest?
- What is the recursive case?
Exercise 2: Fibonacci Sequence
The sequence follows the rule that each number is equal to the sum of the preceding two numbers (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233 … )
These questions will guide you in finding the solution:
- What is the recursive case?
- When do you call the recursive case?
- What is(are) the base case(s)?
When you test your fibonacci method:
-
Check how long it takes to run the method. Run this command in your terminal: time java Fibonacci.java
-
What is the largest number such that fibonacci(number) fits in an int? (does not overflow)
-
HW 21 - More Shapes
DUE DATE:Save your files here:
.../APCSA_1/apcsa-assignments-YourUsername/homework/21_inheritance_more_shapes/
-
Write a superclass Circle. The instance variable should be radius. There will be one constructor to initialize the instance variable. The following methods should be implemented: getRadius(), toString(), getArea().
-
Write a subclass Cylinder which extends from Circle. Define the instance variable height. There will be one constructor to initialize the instance variable. The following methods should be implemented: getHeight(), getVolume(), getArea(), toString(). If you are overriding a method, please use the @Override annotation.
-
Write a Driver.java to test your code.
-
-
HW 20 - Shapes
DUE DATE:Save your files here:
.../APCSA_1/apcsa-assignments-YourUsername/homework/20_inheritance_shapes/
- Create the following classes: Shape (superclass), Rectangle, Triangle.
- Rectangle and Triangle should inherit from Shape.
- Declare private instance variables in class Shape: double height and double width.
- Write a constructor in class Shape to initialize the values for height and width.
- Write public methods in class Shape to get/set height and width values: getHeight(), getWidth(), setHeight() and setWidth().
- Write a method getArea() in both of the subclasses Rectangle and Triangle which calculates and returns the area the result.
- You will need to define the constructors in Rectangle and Triangle classes (which call the Shape constructor).
-
HW 19 - File Handling
DUE DATE:Save your file here:
.../APCSA_1/apcsa-assignments-YourUsername/homework/19_handling_files/
Longest Word
Write a Java program (LongestWord.java) to find and print the longest word inside "my_text.txt". If there are more than one word with the same lenght, you must print the first longest word.
TwoD
Write a Java script (ReadFile.java) that reads the file "2d.txt", creates a 2D array with that data and prints the 2D array.
Find the txt files here.
-
HW 18 - ArrayList
DUE DATE:Save your file here:
.../APCSA_1/apcsa-assignments-YourUsername/homework/18_ArrayList/ArrayListPractice.java
A Driver is not needed. You may write the main method in ArrayListPractice.java
- Return the sum of all the numbers at even positions in the array list.
public int listSumEvenIndexes(ArrayList<Integer> numsList) { }
Examples:
listSumEvenIndexes([1, 2, 3, 4]) → 4 listSumEvenIndexes([8, 16, 10]) → 18 listSumEvenIndexes([5, 0, -10]) → -5
- An array list contains a list of animals. If the animal is a cat (i.e. the animal's description contains the word "cat" or "Cat"), then add it to a new array list. Return the new array list of cats.
public ArrayList<String> listCatty(ArrayList<String> animalsList) { }
Examples:
listCatty(["buffalo", "dog"]) → [] listCatty(["bobcat", "siamese cat", "catbird"]) → ["bobcat", "siamese cat", "catbird"] listCatty(["Cat", "frog", "mouse"]) → ["Cat"]
- Return the sum of the numbers in the array list that are odd and have an even index, or the number is even and its index is odd.
public int listFairlyOddNums(ArrayList<Integer> numsList) { }
Examples:
listFairlyOddNums([1, 2, 3, 4]) → 10 listFairlyOddNums([8, 16, 10]) → 16 listFairlyOddNums([5, 0, 13, 51]) → 18
- Complete the classwork ClimbInfo.
-
HW 17 - SuperArray Exceptions
DUE DATE:Directions are here
-
HW 16 - APLine
DUE DATE:Directions are here
Save your file here: .../APCSA_1/apcsa-assignments-YourUsername/homework/16_APLine/
-
HW 15 - Employee Java class
DUE DATE:-
Create a class Employee
-
Define instance variables
-
Define at least 3 construtor (1 of them default constructor)
-
Declare non-static methods (3 or more)
-
Declare static methods (1 or more)
-
Create multiple objects from your Driver and test all your constructors and all your methods
-
-
HW 14 - Employee class design
DUE DATE:This homework is exactly the same as your classwork, but now we want to design an Employee class.
A big part of using classes in Java is thinking about the design of the class. You’ll need to figure out what information needs to be in the class For instance, in our Rectangle class, we needed to know the width and height. This exercise is a free response question. Imagine that someone comes to you and asks you to design a class that represents a Employee.
-
What instance variables should the Employee class have?
-
What do the instance variables represent? What are the types of those instance variables?
-
What methods would you implement in your Employee class?
Save your file here:
.../APCSA_1/apcsa-assignments-YourUsername/homework/14_classes/employee_class.txt
(or md, docx, pdf files) -
-
HW 13 - Playing with 2D arrays
DUE DATE:- Define a class MyArrayPractice with its main method.
- Write the following methods:
// It should create a copy of the array nums. If you change the new array, nums should not change. public static int[][] copy(int[][] nums){ } // Modify nums. Replace negative values: // When the row index is the same as the column index replace that value with 0. // Otherwise, replace negative values with 1. public static int[][] updateValues(int[][] nums){ }
- Write a few test cases in the main method to test your code.
Save your file here: .../APCSA_1/apcsa-assignments-YourUsername/homework/13_copy_arrays/MyArrayPractice.java
-
HW 12 - CodingBat
DUE DATE: -
HW 11 - String Methods
DUE DATE:Write your own version of the methods: indexOf, compareTo, parseInt. Get this starter code to implement your methods.
Also, using your own words explain how each of those methods works. Type your anwers as comments in your java file.
Save your file here:
.../APCSA_1/apcsa-assignments-YourUsername/homework/11_string_methods/MyStringMethods.java
-
HW 09 - Scanner and CodingBat
DUE DATE:Part 1:
Go inside the folder homework, and create a subfolder 09_snooze. Inside this folder, you will write the following java file:
NoonSnooze.java: This program should ask the user for a number that represents the number of minutes, snooze, that have elapsed since 12:00 pm (noon) and prints the resulting time. Assume a 12-hour clock (with 'am' and 'pm'). You must not use loops. If the snooze value is negative, print a warning message: "No negative values are allowed".
Examples:
If the user input is 50, the output should be 12:50 pm
If the user input is 100, the output should be 1:40 pm
If the user input is 721, the output should be 12:01 am
If the user input is 11111, the output should be 5:11 am
If the user input is -10, the output should be No negative values are allowed
Part 2:
Have fun with CodingBat
-
HW 08 - Scanner
DUE DATE:Save your file here:
.../APCSA_1/apcsa-assignments-YourUsername/homework/08_scanner/NightOut.java
Follow these directions to write your NightOut.java program:
You and a friend are going out for the night. You have decided to treat your friend, so you’re paying for the whole night. However, since you have a fixed amount of money to spend on fun things, you need to track how much the outing will cost so you can update your budget.
Write a program to help yourself estimate what the total cost of the night will be. Your program will estimate the cost by taking the cost of the activities for one person and estimating how much it will cost for two people.
Here’s what you know about your activities: Dinner - you know you typically get cheap dinners, so you expect that your friend’s dinner will be twice as expensive as yoursLaser Tag - since laser tag is charged per person, you and your friend will cost the sameIce cream - you like the triple scoop, but your friend likes a single scoop. Your friend’s ice cream will cost 1/3 as much as yours.
Your program should ask how much YOUR dinner cost, how much laser tag costs per person, and how much YOUR ice cream costs. It should then compute how much your friend’s costs will be based on the information above. Be sure your program takes the input in this exact order. Then print how much dinner will cost (for both of you), how much laser tag will cost (for both of you), and how much the ice cream will cost (for both of you). Then print the grand total for the evening.
Your output should look something like this:
How much does dinner usually cost? 12.63 How much is laser tag for one person? 17.50 How much does a triple scoop cost? 27.00 Dinner: $37.89 Laser Tag: $35.0 Ice cream: $36.0 Grand Total: $108.89
-
HW 07 - Practice Variables and Expressions
DUE DATE:Go inside the folder homework, and create a folder 07_practice. Inside this folder, you will write the following programs:
- Write a Java program (Fractions.java). In this program you will initialize 4 integers that represent each part of two fractions, namely the numerator and denominator of the first fraction and the numerator and denominator of the second fraction. Your program should add the two fractions and print out the result.
For example, a sample program run might look like this:
The numerator of the first fraction is 1 The denominator of the first fraction is 2 The numerator of the second fraction is 2 The denominator of the second fraction is 5 The sum of 1/2 + 2/5 = 9/10
- Write a Java program (WorkShift.java). A doctor works 20 hours, 42 minutes, and 16 seconds in one shift at a hospital. Convert the total shift time into seconds and display that information.
NOTE: You must use at least ONE compound operator (+=, -=, *=, /=, %=) to complete this program.
-
HW 06 - Data Types and Variables
DUE DATE:Data Types and Variables
Directions: Create a homework folder in your assignments repo
.../APCSA_1/apcsa-assignments-YourUsername/homework/
then create a folder 06_variables inside.../homework/06_variables/
Inside that folder, you will write the following programs:
- Write a Java program (Temperature.java) to convert temperature from Fahrenheit to Celsius degrees. You must use variables.
Output:
50.0 degrees Fahrenheit is equal to 10.0 Celsius
- Write a Java program (Calculator.java) that calculates the sum of two numbers (int or double).
Output:
10 + 12 = 22
- Create a file TrickyCalc.java and copy the following code inside. Run the program. Create a file answers.txt or answers.md and respond to the following questions:
- What do you notice about the mySum value?
- What is the value of checkResult, and why do we get that result?
public class TrickyCalc{ public static void main(String[] args){ double mySum = 0.1 + 0.1 +0.1; double tmp = 0.3; boolean checkResult = mySum == tmp; System.out.println("0.1 + 0.1 + 0.1 = " + mySum); System.out.println(mySum + " == " + tmp + " is " + checkResult); } }
- Double check you have your files are organized like this in your repo:
apcsa-assignments-YourUsername classwork 01_hello_world HelloWorld.java 02_art Art.java homework 06_variables Temperature.java Calculator.java TrickyCalc.java answers.txt or answers.md
-
HW 05 - Art
DUE DATE:- Complete CW 1 and 2.
- Remember to complete this form. It is the same one I posted on Piazza.
-
HW 04 - README.md
DUE DATE:Edit your README.md file at home. It should have:
- Name:
- Period:
- Email:
Tomorrow, we will pull the changes using the lab machines.
-
HW 03 - GitHub
DUE DATE:- Configure your machines at home to connect to GitHub with SSH.
- If you did not accept the assignments repo in class, please do it at home. This is the link. After accepting that assignment, you should have a repo created on your GitHub.
- Clone the assignments repo on your home machine:
- Go to your GitHub assignments repository that you accepted for this class. You will see a green button, "Code". You must click on that button and select SSH to have the appropriate link that will allow you to clone your repository and copy the link you see there.
- Create a folder
APCSA_1
anywhere in your home computer.- On your terminal, go inside the folder
APCSA_1
to clone your repository and type:git clone PASTE_THE_LINK_YOU_COPIED_FROM_GITHUB_(git@...)
QUIZ: The summer assignment quiz will be on Monday, September 16.
-
HW 02 - Summer Assignment
DUE DATE:- Follow the next steps to share your CodingBat Summer work with me.
- Log in to your CodingBat account.
- Click on
prefs
Teacher Share
section: type the teacher's email jnovillo@stuy.edu- Click on
Share
- Update the
Memo
section: type YourPeriod_YourLastName_YourFirstName (no spaces) likethis 1_smith_peter
- Click on
Update Memo
- Submit the complete Java program that was assigned on Google Classroom.
- Create a new post on Piazza. This post could be a question or comment about the summer assignment. Reply to at least one peer's comment/question to generate a productive discussion.
- If you do not have a GitHub account, create one please GitHub (you may use any email to create your GitHub account).
-
HW 01 - Forms
DUE DATE:Complete the following forms:
-
CW 34 - Binary Search
DUE DATE:Binary Search
Save your work here: .../APCSA_1/apcsa-assignments-YourUsername/classwork/34_binary_search/BinarySearch.java
Implement the binary search algorithm recursively.
public static int binarySearch(int[ ] arr, int low, int high, int target){ // Solution must be recursive }
-
CW 33 - Hanoi
DUE DATE:Tower of Hanoi
Save your work here: .../APCSA_1/apcsa-assignments-YourUsername/classwork/33_hanoi/Hanoi.java
Mild
Write a function to move n rings from source rod to destination rod, print the moves of each ring.
public static void hanoiMild(int n, char source_rod, char destination_rod, char aux_rod){ YOUR CODE HERE }
Output with 3 rings:
Move ring 1 from source A to destination C Move ring 2 from source A to destination B Move ring 1 from source C to destination B Move ring 3 from source A to destination C Move ring 1 from source B to destination A Move ring 2 from source B to destination C Move ring 1 from source A to destination C
Medium
Write a function to move n rings from source rod to destination rod, print the moves of each ring, and the total number of moves. Check if your solution used the least possible number of moves.
public static int hanoiMedium(int n, char source_rod, char destination_rod, char aux_rod){ YOUR CODE HERE }
Output with 3 rings:
(Print moves as shown in previous method) Total number of moves: 7 The total number of moves (7) is equal to 2^n - 1 (2^3 - 1)
Spicy
Write a function to move n rings from source rod to destination rod, print the moves of each ring, and the list of rings on each rod after each move.
public static void hanoiSpicy(int n, char source_rod, char destination_rod, char aux_rod){ YOUR CODE HERE }
Example:
Current state of rods: Rod A: 3 2 1 Rod B: Rod C: ----------------------- Move disk 1 from Rod A to Rod C Current state of rods: Rod A: 3 2 Rod B: Rod C: 1 ….
-
CW 32 - Number Letter Counts
DUE DATE:Number Letter Counts
Project Euler - Problem 17
Save your work here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/32_recursion_number_letters/NumberLetter.java
This problem must be solved using recursion.
If the numbers 1 to 5 are to are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of "and" when writing out numbers is in compliance with British usage.
Think about the problem:
First how can you implement this method to return the number in letters:
public static String numberToWords(int number) { }
- How can you have a reference to the numbers in words? Should these words be predefined maybe using arrays?
- How should the possible number cases be implemented?
- Handling Hundreds: Greater than or equal to 100
- Handling Tens: 20 to 99
- Handling Teens: 10 to 19
- Handling Ones:Less than 10
- How can you check the value of the number in the recursive method? How to decide whether to use the word for hundreds, tens, teens, or ones?
- What is the base case?
- What is the recursive case?
- What parameter must be sent in each recursive call?
Let's do it from 1-1000 to have the total number of letters in all those numbers:
Declare an integer variable 'result' to store total number of letters for each number from 1 to 1000 call recursive method numberToWords(number here), this return number in words get the length of the word returned from the recursive method and add it to 'result'
Debugging and Testing:
- Debug the program by running it with small inputs.
- Test the program with a range of numbers and verify the results.
-
CW 31 - More Recursion with Strings
DUE DATE:Recursion with Strings
Implement the following methods and save them here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/31_recursion_strings/Strings.java
Print Characters
Print each character of the string.
What String method/s do you need?
What is the base case?
What is the recursive case?
Hint: It can be solved using the head-and-tail algorithm (related to the strategy we learned yesterday), which consists of two parts:
- printing the head of the string, and,
- recursively printing its tail.
public static void printString(String word){ }
Print the string backwards
What String method/s do you need?
What is the base case?
What is the recursive case?
public static void printReverse(String word){ }
Counting Characters in a String
Suppose you are writing an encryption program and you need to count the frequencies of the letters of the alphabet. Let’s write a recursive method for this task.
This method will have two parameters:
- word: string that will be processed
- ch: char to store the target character—the one we want to count.
The method should return an int, representing the number of occurrences of the target character in the string:
What String method/s do you need?
What is the base case?
What is the recursive case?
public static int countChar(String word, char ch) { }
-
CW 30 - Recursion with Strings
DUE DATE:Let's solve the following recursive exercises CodingBat
-
CW 29 - Recursion
DUE DATE:Let's solve the following recursive exercises CodingBat
-
CW 28 - Recursion
DUE DATE:Save your work here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/28_recursion/
-
CW 27 - Console Game
DUE DATE:Time complexity
Save your answers here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/27_console_game
-
CW 26 - Time Complexity
DUE DATE:Time complexity
Save your answers here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/26_time_complexity/answers.md
-
CW 25 - Advent of Code
DUE DATE:Advent of Code 2016
Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/25_advent_of_code/
Due date: Wednesday, November 27 at 11:59 pm
Create an account and join leaderboard
- Go to https://adventofcode.com/2016 and create an account if you do not have one. Otherwise, log in to your account.
- Click on Leaderboard, then click on Private Leaderboard and join our class leaderboard using this code
3215640-7bad14a1
.
Classwork/Homework
-
Required: Work on part 1 problems of days 1, 2, 3, 6.
-
Optional: Choose a part 2 problem of days 1, 2, 3, 6. Or any other harder problem(s).
HAVE FUN!!!
-
CW 24 - Random
DUE DATE:Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/24_random/random.txt
-
CW 23 - Inheritance - Numbers
DUE DATE:Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/23_inheritance_numbers/
-
CW 22 - Inheritance Worksheet
DUE DATE:Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/22_library_books/
-
CW 21 - Inheritance Worksheet
DUE DATE:Save your answers here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/21_inheritance_worksheet/answers.txt
(or md file). -
CW 20 - Inheritance (Electric car)
DUE DATE:Directions here.
Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/20_electric_cars/
-
CW 19 - FRQ
DUE DATE:Work on question 1.
Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/19_frq_appointment_book/solution.txt
(or md file) -
CW 18 - Count Triangles
DUE DATE:Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/18_count_triangles/
-
CW 17 - ArrayList
DUE DATE:Directions have been posted here.
Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/17_ArrayList/
-
CW 16 - Exceptions
DUE DATE:Directions have been posted here.
Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/16_exceptions/
-
CW 15 - Wrapper Classes
DUE DATE:Directions have been posted here.
Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/15_wrapper_classes/
-
CW 14 - SuperArray
DUE DATE:Directions have been posted here.
Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/14_super_array/
-
CW 13 - Fraction Math
DUE DATE:Directions have been posted here.
Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/13_fraction_math/
-
CW 12 - Coordinate V2
DUE DATE:Go here and copy the Point.java and Driver.java in your classwork folder "12_more_coordinates".
Look at the Driver file, and follow the directions.
Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/12_more_coordinates/
-
CW 11 - Coordinate V1
DUE DATE:Part 1
Answer these questions:
- Can you call a static method from a non-static one?
- Or vice versa, can you call a non-static method from a static one?
- Try that in your class Employee, and write your answers as comments at the end of your Employee class.
Part 2
We want to implement (write) a class Point, which fields represent a 2D coordinate (x, y). Let's think about the class design.
- How many instance variable are needed? Private or Public?
- What constructors should be needed?
- What methods do you think should be needed?
- Would it be possible to make the Point class immutable? If so, how?
Write your answers to those questions in a txt, md or any text file.
Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/11_coordinate/answers.txt
Part 3
Go here and copy the Point.java and Driver.java in your folder classwork folder "11_coordinate".
Look at the Driver file:
There are a few questions to respond in that file. Please write your answers as comments in Driver.java
Optional: If you have time you may start writting the Point class. Otherwise, no worries we will work on this on Monday.
DO NOT FORGET TO COMMIT AND PUSH YOUR CHANGES AT THE END OF THE PERIOD.
I will look at this classwork. I will not accept late submissions for this one, exception a justified absence.
-
CW 10 - Design a class
DUE DATE:Imagine that someone comes to you and asks you to design a class that represents a Pizza.
-
What instance variables should the Pizza class have?
-
What do the instance variables represent? What are the types of those instance variables?
-
Methods
Save here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/10_classes/pizza_class.txt
-
-
CW 09 - 2D arrays
DUE DATE:Please complete these exercises.
-
CW 05 - Strings
DUE DATE:Get this starter code and follow those directions.
Save your file here: .../APCSA_1/apcsa-assignments-YourUsername/classwork/05_strings/MyStrings.java
-
CW 04 - Casting
DUE DATE:Create a java file Casting.java and implement a method that:
- Receives 2 integers
- Divides the two ints
- Prints the result
The trick here is that we want the division of the two ints to result in a double! Casting values to doubles will be necessary to solve this exercise. Here is an example:
x = 3 y = 4 Output => 0.75
Save your file here:
.../APCSA_1/apcsa-assignments-YourUsername/classwork/04_casting/Casting.java
-
CW 03 - Expressions
DUE DATE:Give the value and type of each of the following expressions. If the expression does not compile or causes a runtime exception, put an X in both boxes.
Expressions
2 + 5
8 / 10 * 1.5
12 % 7
2 + 3 * 4
2 + 3.0 * 4
1 / 1 / 0
1.0 / 1 / 0
“Happy” + “Face”
“8+2” + “5”
“10” + 8 + 12
2 + 4 + "5" + 6
27 % 4
-
CW 02 - Art
DUE DATE:Write a program to draw some ASCII art using:
System.out.println() System.out.print()
Save here: .../APCSA_1/apcsa-assignments-YourUsername/classwork/02_art/Art.java
-
CW 01 - Hello World and GitHub
DUE DATE:The objective of this exercise is to create a java file, add it, commit and push to a remote repository.
- In your local machine, go to the folder where your assignments repo was cloned ...../APCSA_1/apcsa-assignments-YourUsername/ and create a folder classwork.
- Create a folder 01_hello_world inside the classwork folder.
- Write a java file HelloWorld.java that prints the message "Hello World!".
- Run
git status
. What does it show? - Add the new file to the repo
- Run
git status
again. What does it show this time? - Commit and push the file to your repo.
- Go to GitHub, HelloWorld.java should be there.