Classwork

  1. CW 04 - Scanner


    DUE DATE:

    Save your file here: .../APCSA1/apcsa-assignments-fall-YourUsername/classwork/09_15_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 yours

    Laser Tag - since laser tag is charged per person, you and your friend will cost the same

    Ice 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
    

  2. CW 03 - 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: .../APCSA1/apcsa-assignments-YourUsername/classwork/09_12_casting/Casting.java

  3. CW 02 - Expressions


    DUE DATE:

    Indicate the value and type of each of the following expressions. If the expression does not compile or causes a runtime exception, put an X.

    You do not have to submit this work, but do it on your notebook so you can review it at any time.

    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
    

  4. CW 01 - Hello World and Git


    DUE DATE:

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

    1. In your local machine, go to the folder where your assignments repo was cloned ...../APCSA1/apcsa-assignments-fall-YourUsername/, execute git pull and create a folder classwork.

    2. Create a folder 09_09_hello_world inside the classwork folder.

    3. Write a java file HelloWorld.java that prints the message "Hello World!".

    4. Run git status. What does it show?

    5. 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 classwork folder:

      git add classwork/09_09_hello_world/HelloWorld.java

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

    7. Commit and push the file to your repo.

    8. Go to GitHub, HelloWorld.java should be there.