|
|
Please, make sure that you have added the honor code statement at the top of your Java file:
/* THIS CODE IS MY OWN WORK, IT WAS WRITTEN WITHOUT CONSULTING CODE WRITTEN BY OTHER STUDENTS. _Your_Name_Here_ */ |
The deadline for completing this lab assignment is midnight, today.
mkdir ~/cs170/lab4 cp ~cs170002/share/lab4/* ~/cs170/lab4 cd ~/cs170/lab4 |
In this lab, we will use gedit and javac (not BlueJ !)
java myProgram x y z |
The additional parameters x, y and z are command line arguments.
Example:
public static void main( String[] args ) { .... } |
Explanation:
|
(Remember that computer starts counting at ZERO (0), humans usually start counting at ONE (1)....)
Integer.parseInt( " .... " ) converts a String to an int value Double.parseDouble( " .... " ) converts a String to a double value |
|
UNIX>> javac Arithmetic1.java # Compile UNIX>> java Arithmetic1 1 2 + # Execute 1+2=3 UNIX>> java Arithmetic1 3 2 * # Execute 3*2=6 UNIX>> java Arithmetic1 3 2 ? # Execute Error: invalid operator! |
The program Arithmetic2.java will produce the same results.
|
|
|
When you're done, please exit gedit by clicking on the CLOSE button (located at top-right of the gedit window)
|
|
|
cd ~/cs170/lab4 /home/cs170002/turnin-lab Arithmetic1.java lab4 /home/cs170002/turnin-lab Arithmetic2.java lab4a |
For the Lead TA:
|