Starting from:

$15

Lab Assignment #2 Activities Solution

1. On your own, create a Java program to solve the Chapter 3 Programming Exercise 3.17 (Game: scissor, rock, paper) on page 124 of your textbook. Use either the console or a dialog box for both input and output.
a. Create the source code file, SRPGame.java. Add a block comment at the top of the file to identify your name, file, date, class, assignment, and short description of the program. (3 points)
b. Use the static class method, Math.random() to generate a pseudorandom double number greater than or equal to 0.0 and less than 1.0. Section 3.8 Generating Random Numbers on page 96 in your textbook covers the use of random numbers with a small example. The following Java API provides the documentation on how to use this static method: (5 points)
http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#random()
c. Compile the source code until no errors are found. The Java bytecode file SRPGame.class should be created.
• Common Errors: http://www.cs.armstrong.edu/liang/intro9e/debug.html
d. Run the Java bytecode and observe the results.
e. Attach a hardcopy printout of your source code. (10 points)
f. Attach a hardcopy printout of your sample output using the example in the textbook as your test case. (2 points)
CIS 2571: Introduction to Java
Lab Assignment
College of DuPage 2 CREngland
2. On your own, create a Java program to solve the Chapter 4 Programming Exercise 4.31 (Financial application: computing CD value) on page 172 of your textbook. Use the console for both input and output. Using the static method, System.out.printf, format your console output to match the example given in the textbook. (5 points)
a. Create the source code file, CompCD.java. Add a block comment at the top of the file to identify your name, file, date, class, assignment, and short description of the program. (5 points)
b. Compile the source code until no errors are found. The Java bytecode file CompCD.class should be created.
• Common Errors: http://www.cs.armstrong.edu/liang/intro9e/debug.html
c. Run the Java bytecode and observe the results.
d. Attach a hardcopy printout of your source code. (15 points)
e. Attach a hardcopy printout of your sample output using the example in the textbook as your test case. (5 points)

More products