Programming Assignment 02
Due: Week of Sep. 5 in lab
-
Problem 1.2.14 on page 41 of your book. Name the file and program
ch1sec2prob14.java
. Worth 10pts. Only output a singletrue/false
value. Hint: Use the or operation (operator '||
').
Examples:-
Input: $ java ch1sec2prob14 10 5
Output: true
-
Input: $ java ch1sec2prob14 3 9
Output: true
-
Input: $ java ch1sec2prob14 42 5
Output: false
-
-
Problem 1.2.19 on page 41 of your book. Name the file and program
ch1sec2prob19.java
. Worth 10pts. Only output a single value. You should assume thata
is less thanb
. You cannot use the Java class/utilityRandom
; you must useMath.random()
.
Examples:-
Input: $ java ch1sec2prob19 3 10
Output: 6
-
Input: $ java ch1sec2prob19 3 10
Output: 8
-
-
Problem 1.2.22 on page 41 of your book. Name the file and program
ch1sec2prob22.java
. Worth 10pts. Only output a single value. Note the equation in the book has a slight issue, either changeg
to be negative or change the equation to subtractg*t^2/2
. The final equation would bex_0 + v_0*t - g*t^2/2
.
Examples:-
Input: $ java ch1sec2prob22 10 10 10
Output: -379.01649999999995
-
-
Problem 1.2.29 on page 42 of your book. Name the file and program
ch1sec2prob29.java
. Worth 35pts. Only output a single value, do not output the day as aString
. The input will be inm d y
ordering!
Examples:-
Input: $ java ch1sec2prob29 9 1 2016
Output: 4
-
Input: $ java ch1sec2prob29 3 19 1991
Output: 2
-
-
Problem 1.2.34 on page 44 of your book. Name the file and program
ch1sec2prob34.java. Worth 35pts. Print three values separated by spaces. Do
not assume that the values are unique! Do not use
if-else
statements; instead useMath.min
andMath.max
to assist your solution.
Examples:-
Input: $ java ch1sec2prob34 5 4 3
Output: 3 4 5
-
Input: $ java ch1sec2prob34 5 5 5
Output: 5 5 5
-
-
Bonus. Write a program to output the truth table
values for XOR or exclusive or. Please neatly format the output to show the
values of
a
,b
, anda^b
where a^b is the exclusive or operation. Name the file and programch1sec2bonus.java
. Worth 10pts. Do not hardcode the answer to eacha^b
. Rather compute it with a boolean expression.
Example:-
Input: $ java ch1sec2bonus
Output: a b a^b true true false true false true false true true false false false
-
Grading
Each assignment is graded out of 100% based on a combination of the criteria listed in the assignment description and programming style (e.g., good comments and naming) -- following instructions is extremely important in computer science, train yourself to think like the computer; programming style is important to be able to communicate your solutions to another programmer; both of which you are graded upon.
Specific instructions. Failure to do these steps will result in a loss of points.
- Name each file and program as listed in the instructions.
- Name all variables descriptively.
- Indent all programs appropriately.
- Use comments to help explain the steps and logic of your program.
- The top of your program should have a comment block where the first line
is your name, second line is your section, and third line is a description
of your java program.
//Name: Jory Denny
//Section: 00
//This program debates Batman vs Superman!
Turn in instructions. Each programming assignment is to be turned in before your lab section. You will turn in a soft copy of the assignment (.java or .zip for multiple java files) through blackboard. You will also turn in a hard copy of the assignment in your lab section with a signed coverpage (each program should start a new page of the hard copy).
If there are any discrepencies in grades please see the instructor during his office hours or by appointment (do not discuss with the lab assistants or graders).