Sale!

Assignment 1: Welcome to Java

$30.00

Category:
Rate this product

Assignment 1:
Welcome to Java

Description
The objective of this assignment is to get familiar with Java syntax and writing simple java methods.
As practice for writing code by hand on exams, you are to write the code for each question in hand writing.
You can practice writing and testing the code on a computer, but I suggest you write your solution from
scratch as practice for exams.
Use precise syntax for Java. 1 mark off per compiler and/or run-time error.
All methods should be commented with correct javadoc syntax. 1 mark off per missing/bad comment.
It is very important that your hand writing is neat and legible — if the TA cannot read your
writing, you will lose marks!
Submission
*** All submissions must be submitted on paper in class
Marking
1 ( /5)
2 ( /10)
3 ( /5)
4 ( /5)
5 ( /5)
6 ( /10)
Total ( /40)
This is an individual assignment. You are encouraged to discuss the general concepts of Java syntax, types,
variables, methods, arrays, Strings, ifs, loops, etc. with your classmates, but the specifics for the applications
in this assignment should be done completely individually. Students that copy / share work will be penalized.
1
Name: NSID: Student #:
Question 1: [5 marks]
Write a class named ArrayAverager that implements a method named average to return the average value
of an array of type double, as done in this python snippet:
Write your class based on this provided main method:
2
Name: NSID: Student #:
Question 2: [10 marks]
Write a class named Gambler that implements the following code in its main method. Hint: use Math.rand()
and Math.round(). Note: the console output should be formatted exactly as shown on the right:
3
Name: NSID: Student #:
Question 3: [5 marks]
Write a class named Greeter that implements a method named introductions, that prompts the user for
their name (using the java.util.Scanner class), displays a greeting, and returns the name as a String,
as done in this python snippet:
Write your class based on this provided main method:
4
Name: NSID: Student #:
Question 4: [5 marks]
Write a class named CapitalsCounter that implements a method named countCaps to return the number
of capital letters within a String, as done in this python snippet (hint: use Character.isUpperCase()):
Write a main method to check whether or not the countCaps method correctly returns 5 when given the
the string “IHaveFiveCaptialLetters”. It should print “:)” if successful, or “:(” if failed.
5
Name: NSID: Student #:
Question 5: [5 marks]
Write a class named NumberGuesser that implements the following code within its main method by using a
do loop and the java.util.Scanner class:
6
Name: NSID: Student #:
Question 6: [10 marks]
Write a class named PositiveEvenFinder that implements a method named findPositiveEvens to return
an int array containing all of the positive and even numbers from the provided int array, as done in this
python snippet:
Use the provided main method to test your code – same as this python snippet:
7

Open chat
Need help?
Hello
Can we help you?