LONG pdf Document Syllabus, Cheat Sheet of Java Programming

cs 1102 unit 1 programming assignment pdf

Typology: Cheat Sheet

2022/2023

Available from 07/25/2023

kenson-gaebolae
kenson-gaebolae 🇧🇼

1 document

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 1102 – Unit 1 Programming Assignment
Because this is the first Programming Assignment in the course, the instructions are more detailed
than in later units. You will need to follow the instructions carefully.
First download and install Eclipse IDE for Java Developers.
https://www.eclipse.org/downloads/packages/release/2019-09/r/eclipse-ide-java-
developers;
Once Eclipse is installed, open the Eclipse application. The first time you open it, you will be asked
to select the location for your workspace.
Enter a location or accept the default location.
Click the box for "Use this as the default and do not ask again".
Click "OK".
A new window should appear with large icons.
Click the large arrow icon on the right that displays "Workbench" when you move the
mouse over it.
The window should switch to a complicated grid of icons and window panes. Welcome to Eclipse!
The complexity can be intimidating at first, but many professional Java developers find the many
features to be useful.
Now create a project for this course.
Select "New"->"Java Project" from the File menu.
A dialog box should appear.
Enter the Project name "CS1102".
The default value should work for everything else. Click "Finish".
A pane on the left side of the Eclipse window should show a folder named "CS1102".
Now create the class for your Programming Assignment.
Select "New"->"Class" from the File menu.
Enter the Name "SuperPower" (no spaces).
pf3
pf4

Partial preview of the text

Download LONG pdf Document Syllabus and more Cheat Sheet Java Programming in PDF only on Docsity!

CS 1102 – Unit 1 Programming Assignment Because this is the first Programming Assignment in the course, the instructions are more detailed than in later units. You will need to follow the instructions carefully. First download and install Eclipse IDE for Java Developers. https://www.eclipse.org/downloads/packages/release/2019-09/r/eclipse-ide-java- developers Once Eclipse is installed, open the Eclipse application. The first time you open it, you will be asked to select the location for your workspace.

  • Enter a location or accept the default location.
  • Click the box for "Use this as the default and do not ask again".
  • Click "OK". A new window should appear with large icons.
  • Click the large arrow icon on the right that displays "Workbench" when you move the mouse over it. The window should switch to a complicated grid of icons and window panes. Welcome to Eclipse! The complexity can be intimidating at first, but many professional Java developers find the many features to be useful. Now create a project for this course.
  • Select "New"->"Java Project" from the File menu. A dialog box should appear.
  • Enter the Project name "CS1102".
  • The default value should work for everything else. Click "Finish". A pane on the left side of the Eclipse window should show a folder named "CS1102". Now create the class for your Programming Assignment.
  • Select "New"->"Class" from the File menu.
  • Enter the Name "SuperPower" (no spaces).

As Eck (2019) suggests in Section 2.6.6, ignore the warning that "the use of the default package is discouraged" (63).

  • Click "Finish". The new file "SuperPower.java" should appear in the center pane for editing. It should have a class declaration for "SuperPower" with an empty definition block. Now give your class something to do! Add a "main" method, which will be run as your program.
  • Type in the following method definition and output statement inside the definition block of the class (between the first "{" and last "}"). public static void main(String[] args) { System.out.println("SUPER POWERS TO THE RESCUE!"); } Notice how the editor automatically adds the closing "}" and provides automatic completion as you type the "System.out.println" call. This automatic completion can be distracting at first, but it is useful for experienced programmers. If you make mistakes in typing this method definition, you may see small warning icons to the left of the lines of code that have problems. For example, if you type "system" instead of "System", a warning icon will appear left of that line. Move your mouse over the icon to see a message like "system cannot be resolved". If you type the method definition correctly, no error icons should appear. Time to run your program!
  • Click the Run icon, a small green circle with a white triangle at the top right of the Eclipse window. A dialog box should appear asking if you want to save your resources (your Java code file).
  • Click the box next to "Always save resources before launching".
  • Click "OK". The IDE will now compile and run your program. The text "SUPER POWERS TO THE RESCUE!" should appear in a Console pane at the bottom of the Eclipse window. But Java was designed for graphical user interfaces (GUIs) more than text output. Change your program to use some of the built-in graphics features of Java.
  • Add the following line at the top of your code, before "public class SuperPower". import javax.swing.JOptionPane;

The Message dialog should celebrate your super power.

  • Click "OK". The Message dialog should disapper, ending your program. As a final feature, change the user's input so it is all capital letters. Use the "toUpperCase" method that is described in Section 2.3.3 of Eck (2019). Add the following line after the initialization of "power" and before the "showMessageDialog" call that uses it. power = power.toUpperCase(); The method "toUpperCase" is a function that returns an all-upper-case translation of the String "power". The assignment with "=" then resets "power" to refer to this modified String instead of the original.
  • Click the Run icon.
  • Enter a power with lower-case letters.
  • Confirm that the resulting message is all upper case. Congratulations! Now you are ready to submit your assignment. First look up how to take screen shots on your device. Then run your program again.
  • Click the Run icon.
  • Enter a power with low-case letters.
  • Take a screen shot of this Input dialog box before clicking "OK".
  • Click "OK".
  • Take a screen shot of the Message dialog. Upload the following for your Programming Assignment submission.
  • SuperPower.java
  • Screen shot showing the Input dialog with some lower-case input.
  • Screen shot showing the Message dialog with all upper-case output.