time due | submission file |
---|---|
11:00 PM Friday 2 November, 2007 | csci/201/Homework5 |
At exactly 11:00 PM, on Friday, 2 November, 2007, a program will be run to copy your homework out of your csci/201/Homework5 directory on the UNCA Computer Science server. Your homework must be stored in this directory exactly as specified a bit later in this handout in order to be copied. Programs that are not stored correctly will not be graded and will be considered unsubmitted.
At 11:00 PM on each of the three following days, additional attempts will be made to copy programs that are submitted late. There is a penalty of 15% for each day a program is submitted late.
Your programs begins by asking the user to enter a small positive
integer. This integer will be the size of two arrays of doubles
(double[]
) your program will create.
Your program will then ask the user to enter numbers to fill in
the double arrays.
Here is a example of how the first part of your program should behave.
Enter the size of each vector 5 Enter the 5 numbers for vector 1 201 2007 42 100.03 -3 Enter the 5 numbers for vector 2 2 4 6 8 10
Now that the two vectors are loaded, your program will process a series of five different operators.
After each operator is entered, your program should perform the specified operator and, if the operator is not q, print the value of the two vectors.
Here is an example of what your program should respond to a sequence of operators.
Enter operator (?, +, -, #, or q) ? Vector 1 0 1 2 3 4 201.00 2007.00 42.00 100.03 -3.00 Vector 2 0 1 2 3 4 2.00 4.00 6.00 8.00 10.00 Enter operator (?, +, -, #, or q) + Vector 1 0 1 2 3 4 203.00 2011.00 48.00 108.03 7.00 Vector 2 0 1 2 3 4 2.00 4.00 6.00 8.00 10.00 Enter operator (?, +, -, #, or q) # Vector 1 0 1 2 3 4 2.00 4.00 6.00 8.00 10.00 Vector 2 0 1 2 3 4 203.00 2011.00 48.00 108.03 7.00 Enter operator (?, +, -, #, or q) - Vector 1 0 1 2 3 4 -201.00 -2007.00 -42.00 -100.03 3.00 Vector 2 0 1 2 3 4 203.00 2011.00 48.00 108.03 7.00 Enter operator (?, +, -, #, or q) ? Vector 1 0 1 2 3 4 -201.00 -2007.00 -42.00 -100.03 3.00 Vector 2 0 1 2 3 4 203.00 2011.00 48.00 108.03 7.00 Enter operator (?, +, -, #, or q) q
Again we suggest you use the following method to read the operator as was done in Homework 4.
public static char nextOperation(Scanner s) { try { return s.next().charAt(0) ; } catch (Exception e) { return 'q' ; } }
Your completed program must be stored within
a subdirectory
csci/201/Homework5 of your Linux home
directory. If you create a project named Homework5
at project location csci/201 as was done in
the first week's lab this will happen automatically.
If you complete this assignment on your "home" system,
you still must:
(1) create a Homework5
projects;
(2) accept the defaults when creating your project thus
creating a program with a Main
class within
the homework5
package;
(3) create a csci/201/Homework5
directory within your Linux account to store your work; and
(4) copy the src/homework5/Main.java
of your Homework5
project at home into your
csci/201/Homework4 directory at UNCA.