![]() |
Department of
Mathematics and Computer Science |
|
Math 10 -- Fall, 2001
|
|
15 points DUE: NOON: Friday, November 16, 2001 NO Extensions! |
Work from your C++ program and try to make a line for line correspondence whenever possible. The sample code given in the Java class notes should be your basic model. Most of the assignment and declarations statements should transfer over without difficulty. You should declare variables as double rather than float, however. The other major change will be in the output statements and in the omission of the output "manipulator" functions.
You do not need to write and use any functions -- the main point of this assignment is to realize that shifting from one language to another sometimes is not a major endeavor, especially when shifting from C/C++ to Java.
To induce spacing between numbers or strings printed on the
same line, you can use the "tab" control symbol, \t
within a quoted string to tab over a few spaces. (This also
works in C++, e.g..,
cout << miles << '\t' << nauts << endl;
will tab over several spaces between the value of miles
and the value of nauts.)
Since the use of disk files is much more complicated in Java than in C++ (see Java Notes J4 for file IO information), it is best to write this program on the departmental Linux machine (i.e., on pascal) and "capture" the output by file redirection. In other words, after you have the program running correctly, redirect your output to an output file using the > sign on the command line after the java mp9 command.
As usual, use good programming style, and turn in both the program (source file) and the output file.
This page is maintained by Dennis C. Smolarski, S.J. dsmolarski@math.scu.edu Last changed: 30 September 2001.