Objective: Identify and fix the compiler and logic errors in a program and to write simple programs using some of Java's available class, simple control structures, and arrays.
Due: Before the next class on Friday, Sep 12.
Create a directory for assign1
within
your cs209
directory.
Save Assign1.java into
your assign1
directory.
This program contains at least 5 errors. Some are compiler errors that the compiler will catch. Others are logic errors that the compiler won't catch.
Comment out the original code and note the cause of the error. Then, correct the code.
You may want to run this program with multiple command-line
arguments. Specifically, try running the program with and
without cow
as a command-line argument.
The new system of scoring an Olympic gymnast is based on two separate panels of scores. The A panel judges the requirements, difficulty, and connections of a routine. The scoring starts at zero and then adds points accordingly. The B panel judges the execution of a routine, and the scoring starts at 10 with points deducted accordingly for execution and for any applicable violations such as stepping out of bounds or being over the time limit.
For each panel of judges, the lowest and highest scores are dropped (to prevent judges from biasing the results) and then averaged. The two panels are then added together for the final score. A very good score will range in the 15s and 16s.
Your task: Assume an average difficulty score of 6.0. Represent the judges' execution scores as an array of floats or doubles. (You cannot assume that the array is sorted from initialization.) Calculate the average score, as described above. Display the judges' scores and the final score.
Example output:
Gymnastics Score ---------------- Judges Execution Scores: 8.0 8.3 8.5 8.8 8.9 9.1 Average Execution Score: 8.625 Average Difficulty Score: 5.7 The Final Score: 14.325
Save the output from one of your runs in the
file scores.out
.
Your program should take in a string from the command line and print the string backwards.
Use a string as an accumulator for the reverse of the original string. Go through the original string character by character, from the end of the string to the beginning. (What String method should you use?)
Example output for java ReverseString stars
:
stars backwards is srats.
If the user does not enter a string on the command line, print a useful error message.
Example output for java ReverseString
:
Error: Need a command-line argument.
Save the output from several runs of the program
in the file reverse.out
. After running the
program the first time, use >>
to put additional output into the same
file. For example:
java ReverseString stars > reverse.out
java ReverseString banana >> reverse.out
Copy your assign1
directory into your
turnin directory,
i.e., /home/courses/cs209/turnin/yourusername
.
For example:
cp -r assign1 /home/courses/cs209/turnin/sprenkles/
There is no printed part of this assignment.
You will be evaluated based on