Download Assignment #1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Elementary mathematics wikipedia , lookup

Transcript
Assignment #2
Write a Java program to calculate the solution of a quadratic equation of the form:
a * x^2 + b * x + c = 0
where x^2 means x to the second power, and a, b, and c are real numbers.
The program shall meet the following requirements:
1) It shall run in a loop, whose maximum number of iterations is an integer number entered into a
program during command line execution, for example:
> java QuadEquation number
2) It shall receive values of coefficients a, b, and c, from the keyboard, once per iteration,
By prompting an operator as follows:
Please enter coefficient a: <operator enters a>
Please enter coefficient b: <operator enters b>
Please enter coefficient c: <operator enters c>
<one empty line should follow each three prompts>
3) It shall write results onto a disk file, named results.dat, in the following format (once for each
iteration, unless there are no solutions):
a = <value>; b = <value>; c = <value>;
Root1 = <value>; Root2 = <value>;
4) In case there are no solutions, because the discriminant is negative, it shall write the following
message to the screen (followed by one empty line):
For a=<value>, b=<value>, c=<value> there are no solutions.
5) It shall print to the screen the following information:
a) Upon startup:
This program calculates roots of a quadratic equation.
Please enter data as instructed.
b) Upon completion:
The program has completed operation.
See results in the file results.dat
6) It shall use Java exceptions to deal with file IO.



Form of submission: source code on a diskette with your name written on it
Deadline: October 7 (Tuesday), in class
Grade: Max 15 pts;
Tardiness: 2 pts per day