The purpose of this assignment will be to set up a development environment to use for the remainder of the quarter as well as refresh yourself with CSE 8A concepts.
The Java code you submit in the programming assignments must compile and run on Java 10 on Linux. If you use the lab machines in the CSE building, then you should be using the correct programming language version and the correct operating system version by default. We'll confirm the compiler version as part of this assignment. In-lab and remote programmers will use the correct compiler and operating system by default, since your connection allows you access to data and programs on the lab machines. Local programmers have additional problems and must check their Java programs against ieng6. To earn credit, your Java code must be for
Please refer to these style guidelines when working on the assignments.
Points for style will not be deducted for PA1. Starting from PA2, style will be part of your overall assignment grade. However, we expect that you try to follow the style guidelines for this PA1 because it is good practice. We will provide you with feedback in your grade report on what can be improved in terms of style and what is good.
TO DO: you are required to sign the Academic Integrity Form electronically after completing the Academic Integrity Tutorial. The form can be found here.
Please fill out the following 2 surveys as each one will be worth 1 point among your overall PA1 score.
Please read the environment-setup.md document that details how to access a development environment through the lab machines or remotely as well as setup a local development environment on your laptop. As a way to ensure you have access to a proper environment for the rest of the quarter (either through the lab computers or through your own computer), please compile and execute the Test.java
file, which should open up a popup window indicating that your development environment has been set up correctly.
TO DO: set up or get access to a correct development environment as stated in environment-setup.md. IMPORTANTLY, ensure that X11 forwarding is enabled if accessing the environment remotely, otherwise the popup window will not be displayed. Compile and execute Test.java
. Screenshot the popup window (containing a special message) that opens from compiling and executing the Test.java
file as proof that you have access to a development environment. Name this screenshot file exactly as environment-setup.png
otherwise no credit for this section will be given. Put this screenshot file in the same folder where your Test.java
file is located.
Note: we have provided you with a vimrc
file in the starter code that can be used if you decide to use Vim as your preferred text editor for the assignment.
TO DO: you will complete 4 exercises that cover what you have learned in CSE 8A. Please work within the starter code file PA1.java and only add code where it specifically tells you to.
In this exercise, you will write the printASCIIValues(String input)
method. This method should print out the ASCII integer value of each character in the String input
argument next to the actual character value. Assume that input
will always be valid and not null.
For example, let's say printASCIIValues("Java")
is called. 'J' has an ASCII value of 74, 'a' has an ASCII value of 97, 'v' has an ASCII value of 118, and 'a' has an ASCII value of 97. The following would be printed:
J 74
a 97
v 118
a 97
Ensure that the output is printed exactly as it is above - <character><space><ASCII value>
. The method should be case sensitive as capital and lowercase versions of a same letter have different ASCII values.
In this exercise, you will write the rotate1DArray(int[] input, int rotations)
method. This method should return a one-dimensional int array that represents the rotated version of the input
array argument. The number of rotations to perform depends on the rotations
argument and each rotation will be done in the right direction. Assume that input
will always be valid and not null.
Example input array:
1, 2, 3, 4, 5
6 % <length of the array>
operation)-14 % <length of the array>
operation)In this exercise, you will write the rotate2DArray(int[][] input, int rotations, boolean rotateRows)
method. This method should return a two-dimensional int array that represents the rotated version of the input
2D-array argument. The number of rotations to perform depends on the rotations
argument, each row rotation will be done in the downwards direction, and each column rotation will be done in the right direction. If the rotateRows
value is true, then rotate the rows of the 2D input
array. If false, rotate the columns of the 2D input
array. Assume that input
will always be valid and not null.
Tip: try using the rotate1DArray(int[] input, int rotations)
method when rotateRows
is false to avoid rewriting code.
Example input array:
1, 2, 3
4, 5, 6
7, 8, 9
In this exercise, you will write the printIntroduction(String name)
method. This method takes as input a String called name
, where you may assume name
can be a maximum of 30 characters and can only consist of spaces/uppercase letters/lowercase letters. name
can also be null or an empty String. This method should print out 5 lines where: the 1st and 5th lines contain just asterisks; the 2nd and 4th lines start with an asterisk, followed by space characters, and end with an asterisk; and the 3rd line starts with an asterisk, followed by a space character, then followed by the message "Hello <name>
! Welcome to CSE 8B!", then followed a space character, and ends with an asterisk. All 5 lines should contain the same number of characters, so the 3rd line (line that contains the message) defines the length of the rest of the lines. If the name
argument is null or is an empty String (""), then the message will simply be printed without a name (see Example 1 below).
name
is null or is an empty String (""), the output will be:name
is "Alicia Keys", then the output will be:name
is "William", then the output will be:name
is " " (1 space character), then the output will be:name
is " " (4 space characters), then the output will be:Please fill out a weekly reflection survey here