Homework

  1. HW 07 - Scanner


    DUE DATE:

    Go inside the folder homework, and create a subfolder 09_15_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

  2. HW 06 - Practice Variables and Expressions


    DUE DATE:

    Go inside the folder homework, and create a folder 09_12_practice. Inside this folder, you will write the following programs:

    1. 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
    
    1. 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.

    Quiz Reminder

    The Summer Assignment Quiz will be on Tuesday, September 16th

  3. HW 05 - Data Types and Variables


    DUE DATE:

    Data Types and Variables

    Directions: Create a new folder named 09_10_variables inside your homework directory in your assignments repository: .../APCSA1/apcsa-assignments-fall-YourUsername/homework/09_10_variables

    Inside this folder, write the following programs:

    1. 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

    1. Write a Java program (Calculator.java) that calculates the sum of two numbers (int or double). You must use variables.

    Output:

    10 + 12 = 22

    1. 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);
       }
    }
    
    1. Don’t forget to add your new files to Git, then commit and push your changes. After that, go to GitHub and verify that your files are there. I will not accept any excuses tomorrow if your homework is missing.

    2. Double check that your files are organized like this in your repo:

    apcsa-assignments-YourUsername
      classwork
        09_09_hello_world
          HelloWorld.java
      homework
        09_09_welcome
          Welcome.java
        09_10_variables
          Temperature.java
          Calculator.java
          TrickyCalc.java
          answers.txt or answers.md
    

  4. HW 04 - Git commands practice


    DUE DATE:

    The objective of this homework is to create a java file, add it, commit and push to a remote repository.

    1. In your local machine at home, go to the folder where your assignments repo was cloned ...../APCSA1/apcsa-assignments-fall-YourUsername/, execute git pull and create a folder homework.
    2. Create a folder 09_09_welcome inside the homework folder.
    3. Write a java file Welcome.java (this should be the path ...../APCSA1/apcsa-assignments-fall-YourUsername/homework/09_09_welcome/Welcome.java). In this program, you should introduce yourself. Print two lines to the console using the System.out.println() method.

    In the first line, state your name, and in the second line state your favorite hobby.

    Your output should be in the following form:

    My name is ...
    My favorite hobby is ...
    
    1. Run git status. What does it show?

    2. To add the new file to the repository, run the following command from the root (top-level, ...../APCSA1/apcsa-assignments-fall-YourUsername/) of your repo, not from inside the homework folder:

      git add homework/09_09_welcome/Welcome.java

    3. Run git status again. What does it show this time?

    4. Commit and push the file to your repo.

    5. Go to GitHub, Welcome.java should be there.

    6. Tomorrow, we will pull the changes using the lab machines.

  5. HW 03 - Git


    DUE DATE:

    1. Set up SSH
      Configure your home computer to connect to GitHub using SSH, if you have not done that already.

    2. Accept the Assignments Repository

      • If you haven’t already, accept the assignments repository using this link.
      • After accepting, a repository will be created under your GitHub account.
      • If you run into any issues, contact me.
    3. Clone the Assignments Repository

      • Open your GitHub assignments repository for this class.
      • Click the green Code button, select SSH, and copy the link provided (it will look like git@...).
      • Create a folder named APCSA1 anywhere on your computer.
      • Open your terminal, navigate inside the APCSA1 folder, and run:
        git clone PASTE_THE_LINK_YOU_COPIED_FROM_GITHUB

    Quiz Reminder

    The Summer Assignment Quiz will be on Tuesday, September 16th.

  6. HW 02 - Summer Assignment, Piazza, Git


    DUE DATE:

    Summer Assignment

    1. 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) like this 1_smith_peter
    • Click on Update Memo
    1. Submit the complete Java program that was assigned (Google Classroom).

    Piazza

    1. Post a question or comment about the summer assignment. Feel free to reply to peer's comment/question to generate a productive discussion.

    GitHub

    1. Set up Git and SSH keys on your home computer and practice using Git commands. If you have any questions, post them on Piazza, and I encourage everyone to help your peers by answering those questions.

  7. HW 01 - Forms


    DUE DATE:

    Complete the following forms: