CSSE 220: Object-Oriented Software Development
HelloWorldAgain
Work on this exercise by yourself,
but be quick to ask questions of your instructor, student assistants and classmates as desired.
Goals
The goals of this exercise are to reinforce the concepts from the
HelloWorld project:
- Familiarize you with our development environment (Eclipse)
- Ensure that you can create a simple program from scratch
- Introduce you to Version Control from within Eclipse (i.e., using Subclipse)
- Help you transfer your skills from C and Python to Java, especially:
- Declaring variables
- Printing on the console
- Defining and calling methods (aka functions)
- Writing for loops and if statements
Instructions
- Read my solution to the HelloWorld project.
- My solution includes a printIntegersWhoseTangentIsNegative method
that was NOT part of the assignment. Use it as an example for your work on this project.
- In Eclipse, create a new Java project called HelloWorldAgain
- Add a single class, also called HelloWorldAgain, with a main method.
- Write a method called squares that takes an integer n and prints the squares of the integers from 1 to n
on the console, each on a line by itself.
- For example, squares(6) should print:
1
4
9
16
25
36
- Test your method by calling it from main several times with different values for n.
- Write a method called cosines that takes two integers start and stop
and prints the cosines of the integers from start to stop, inclusive,
on the console, each on a line by itself.
- For example, cosines(3, 6) should print:
-0.9899924966004454
-0.6536436208636119
0.28366218546322625
0.9601702866503661
- Test your method by calling it from main several times with different values for start and stop.
- Write a method called bigCosines that takes two integers start and stop
and prints on the console, each on a line by itself,
all the integers from start to stop, inclusive,
whose cosine is bigger than 0.8.
- For example, bigCosines(4, 30) should print:
6
12
13
19
25
- Test your method by calling it from main several times with different values for start and stop.
- Make sure your code uses good style, in particular:
- Classes, methods and variables have informative names
- Classes and methods have a comment that describes what they do
- Code is formatted as per Control-Shift-F
- Add your project to your personal repository.