Skip to main content

Homework 0: Hello World & Errors

Pre-course survey (2 points)

Please fill out this short survey. Your answers will help your instructor get to know you and learn what you hope to get out of this course. This will help me modify the course to best fit your interests.

Write a program, Fortune.java, which prints a fortune like the ones typically found in fortune cookies. Use the program as a starting point.

1.  // Name:
2.  // Date:
3.  // Description: Print a fortune to the console
4. 
5.  public class Fortune {
6. 
7.    public static void main(String[] args) {
8.      System.out.println("Hello World!"); // todo: your message here
9.    }
10. } 

You can download Fortune.java from the course website using the following command:

wget https://cs.brynmawr.edu/cs113//website/hws/hw00/Fortune.java

Below is an example of compiling and running the program in the command line:

$ javac Fortune.java
$ java Fortune
A journey of a thousand miles begins with a single step.

Dont forget: make sure to fill in the header in Fortune.java.

Error Messages (10 points)

Programming is very similar to writing. A first draft is always messy. Its no different when programming, you’ll make plenty of mistakes when first writing any program. A nice thing about programming is that the compiler is your friend who will tell you the mistakes that you’ve made. First delete the binary file (Fortune.class) that was created when you compiled Fortune.java.

In this part of the assignment, we are going to make some mistakes on purpose. For each of the following changes 1) copy the error message you see when compiling the program and 2) a simple explanation of what you think that message might mean. If the program compiles, try running it.

Save your answers in a new file called ERRORS.txt. After making each edit listed below, revert the edit so that the file is the same as when you ended the last part of this assignment.

  1. Remove the ; at the end of line 8.
  2. Change Fortune in line 5 to fortune.
  3. Change main to blah in line 7.
  4. Remove the } in line 10.
  5. Remove the } in line 9.
  6. Create your own error (describe the change in ERRORS.txt)

What is Computer Science? (5 points)

Read Computer Science: Not about Computers, Not Science.

In a new file called HW00_READING.txt answer the following questions:

  1. According to the author, if computer science is not about computers, then what is it about?
  2. In your own words, what is an algorithm.
  3. According to the author, why is computer science not a science?
  4. The author writes that he “often find[s] that eager undergraduates are either excited about something that is not CS, or stems from an advanced topic that definitely is CS.” Are there any things that you are excited about that you thought is CS but might not fit under the author’s definition of CS? Alternatively, are there any advanced topics that excited that you now think are definetly CS based on teh author’s definition.
  5. Feel free to provide any additional feedback.

Submitting

Submit the following files to the assignment called HW00 on Gradescope:

  1. Fortune.java
  2. ERRORS.txt
  3. HW00_READING.txt

Make sure to name these files exactly what we specify here. Otherwise, our autograders might not work and we might have to take points off.