Computer Science 261
Programming Assignment #1
Due: Monday, Sept. 16
Purpose: The purpose of this assignment is to
- Start getting comfortable with the form of a Java program
- Start getting familiar with the JCreator tools
- Make sure that the handin system works correctly
- Review some basics from CSci 161
- Please write a program, called quad.java, which accepts three
real (double) numbers from the user (call them A, B, and C for
now) and which then calculates and prints the solution(s) to the
quadratic equation A*x^2 + B*x + C = 0 according to the following
rules:
- If A = B = 0 then there is no solution, else
- If A = 0 then the solution is x = -C/B
- Otherwise, calculate D = B^2 - 4*A*C
- If D < 0 there are no (real) solutions
- If D = 0 the solution is x = -B/(2*A)
- Else there are two solutions: x = (-B+sqrt(D))/(2*A) and
x = (-B-sqrt(D))/(2*A)
- As a part of the quad.java program, include in your comments a
test set adequate to reasonably test correct input (don't worry
about testing errors at this point). Give brief justifications for
each test.
- Write a second program, called Fibonacci.java, which accepts
an integer N and then calculates the Nth Fibonacci number three
ways
- By using a loop without any functions or arrays
- By using an array
- By using a recursive function.
We will discuss the details of submitting programs Monday.
Some notes:
- You will need to set up a workspace on your filestore on
Alexandria (drive H:)
- Call it anything you want to
- Create an empty project (again File -> New -> project).
Be sure to select an empty project (we will look at some of the
other options later)
- Create a Java file (File -> New etc.)
- If not automatically added to your project, go to Project
-> add files and add the file to the project.
- One trick is to keep the same project and workspace, and to
change the files around. To remove a file from the project, make
sure that the window is closed (remember that we discovered this
today in class), select the project, and then select delete from
the edit menu.
Any questions/problems? Please ask!