CPSC 150 Laboratory Manual. Lab 1 Introduction to Program Creation

Similar documents
CPSC150L Lab 0 Lab Set Up

Instructions PLEASE READ (notice bold and underlined phrases)

CSC116: Introduction to Computing - Java

Instructions. First, download the file

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

CSC116: Introduction to Computing - Java

Department of Computer Science University of Pretoria. Introduction to Computer Science COS 151

CPS109 Lab 1. i. To become familiar with the Ryerson Computer Science laboratory environment.

Linux File System and Basic Commands

CSE 101 Introduction to Computers Development / Tutorial / Lab Environment Setup

CSC116: Introduction to Computing - Java

CS Fundamentals of Programming II Fall Very Basic UNIX

Lab 1 1 Due Wed., 2 Sept. 2015

You should see something like this, called the prompt :

ModeChanger

Summer Assignment for AP Computer Science. Room 302

The Command Shell. Fundamentals of Computer Science

CS 177 Recitation. Week 1 Intro to Java

Lesson 04: Our First Java Program (W01D4

CS 209 Section 52 Lab 1-A: Getting Started with NetBeans Instructor: J.G. Neal Objectives: Lab Instructions: Log in Create folder CS209

Semester 2, 2018: Lab 1

Cmpt 101 Lab 1 - Outline

Chapter 2. Editing And Compiling

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

When you first launch CrushFTP you may be notified that port 21 is locked. You will be prompted to fix this.

C02: Overview of Software Development and Java

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

Getting started with UNIX/Linux for G51PRG and G51CSA

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Securexam Mac User Guide

Getting Started with Python and the PyCharm IDE

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide

Students Guide to Desire2Learn

ASSIGNMENT 5 Objects, Files, and More Garage Management

RWT Network System Installation Guide

ENCM 339 Fall 2017: Editing and Running Programs in the Lab

Lab 1 Introduction to UNIX and C

CS 201 Software Development Methods Spring Tutorial #1. Eclipse

CSCI 161: Introduction to Programming I Lab 1a: Programming Environment: Linux and Eclipse

Lab 1 Introduction to UNIX and C

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.)

ASSIGNMENT 5 Objects, Files, and a Music Player

Project 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with

ECE297 Quick Start Guide Wiki

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

STA 303 / 1002 Using SAS on CQUEST

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

CS 112: Intro to Comp Prog

Software and Documentation

EECS 1710 SETTING UP A VIRTUAL MACHINE (for EECS labs)

CS10001: Computer Literacy Lab Assignment #4

Getting Started with UNIX

Code Ninjas: Introduction to Computer Science. Macomb Science Olympiad Presented by Swati Dharia

Eclipse Environment Setup

Getting Started with Command Prompts

Flash Video Encoder CS3 Fetch Microsoft Office 2004 (Excel, imovie. Powerpoint, Word, Entourage) itunes

Clean Up Team Lab 10 Points. Cisco Switch Lab I Individual Lab 25 Points

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

Once you have installed MobaXterm, open MobaXterm. Go to Sessions -> New Session, and click on the SSH icon.

Guided Tour (Version 3.3) By Steven Castellucci as Modified by Brandon Haworth

A Linux Virtual Machine for CS-2011 Projects

Laboratory Exercise #0

Welcome to Mac OS X, the world s most advanced operating system. This book helps you start using Mac OS X. First install the software, then discover h

CS1110 Lab 1 (Jan 27-28, 2015)

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

ADOBE DREAMWEAVER CS4 BASICS

Getting Started in Your Blackboard 5 Course

These two items are all you'll need to write your first application reading instructions in English.

Batch Watermark Creator Software

Moodle FAQ. How do I login to Moodle?

ITI1120 Fall Lab 0 Introduction to the Lab Environment

Getting Started (1.8.7) 9/2/2009

Creating Pages with the CivicPlus System

Cisco Switch Lab II (1-3 Persons) Individual/Team Lab 35 Points

Class 1: Homework. Intro to Computer Science CSCI-UA.0101 New York University Courant Institute of Mathematical Sciences Fall 2017

You will need to download the Java software development kit from

Use the Apple menu to change settings, get Mac OS X software, open recent items, and restart or shut down your computer.

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to:

2013 EDITION. V-Camp Student. Guide. INTERACTIVE GUIDE Use the buttons shown below to navigate throughout this interactive PDF BACK

Why Operating Systems? Topic 3. Operating Systems. Why Operating Systems? Why Operating Systems?

CSCI 201 Lab 1 Environment Setup

Preferences & Notifications Statistics Glossary Interpreting the Similarity Report

Website Development Komodo Editor and HTML Intro

ACADEMIC TECHNOLOGY SUPPORT

SECTION 1 INTRODUCTION

Tips from the experts: How to waste a lot of time on this assignment

Week 2: Data and Output

Prometheus V4.0. Table of Contents. Prometheus Student Help Guide 1. Introduction...2. Outside a Course...5. Outline...7. Testing...8. Grade Book...

This is a combination of a programming assignment and ungraded exercises

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

CMSC 201 Spring 2017 Lab 01 Hello World

Getting Started with. Contents. Getting Started ! System Requirements... Before You Register # Registering for Your Course...

1 Build Your First App. The way to get started is to quit talking and begin doing. Walt Disney

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists

Chapter 4 The Companion Website A Unique Online Study Resource 4.1 Locating Companion Web sites

Read Naturally SE Software Guide. Version 2.0

Computer Hardware. Java Software Solutions Lewis & Loftus. Key Hardware Components 12/17/2013

FirstClass and the NLC Intranet. Version 12

SmartCVS Tutorial. Starting the putty Client and Setting Your CVS Password

Contents. Signing In... 3 Answering Your Personal Security Question... 4 Forgetting Your Password... 4 Exploring the Learning Center Interface...

Transcription:

CPSC 150 Laboratory Manual A Practical Approach to Java, jedit & WebCAT Department of Physics, Computer Science & Engineering Christopher Newport University Lab 1 Introduction to Program Creation Welcome to the laboratory exercises that accompany the lecture course CPSC 150: Computers and Programming I. Although these lab exercises support the material presented in lectures it should not come as a surprise that at times the lab and lecture may cover topics at different times or with a different emphasis. This caveat notwithstanding, lab and lectures should complement each other quite often. In this first lab, we will get acquainted with the software that will support our main goal: creating computer programs using the Java programming language. It is not the intention of this first lab to emphasize java programming; instead you are to take the Java programs provided to you and learn how to use the tools in this lab to create and test programs. If you have questions regarding why a particular program behaves as it does, feel free to ask your lab instructor, but understand that the details of the programs will be addressed in lecture and in following labs.

Structure of the Lab Grading: Labs have questions and exercises that you should complete. Pay careful attention to the instructions regarding how the questions are to be graded. In a few cases you will simply show your instructor your work. In other instances, you will use an automated grader to check the correctness of the program. This automated grader is named WebCAT and the process for using WebCAT is included in this lab. The number of questions you answer and the exercises you complete will determine your total grade. Your instructor will give you the grading scale for your particular section. As is the case with most courses, instructors of each section have the latitude to determine the details of their own grading policy, so be sure to ask your instructor for details associated with the grading of each lab. The philosophy of the lab organization is to provide you with an instructor to assist you with the questions you encounter, so that your efforts are more efficient. It is expected that you will consult with other students in the lab to complete your work as the course incorporates a team programming philosophy, encouraging you to work together, but be careful to understand the difference between working together and copying the work of others. WebCAT is integrated into the grading aspects of the course so that your instructor can focus on answering your questions instead of determining the correctness of your programs. Materials: Each lab activity except this first one will require that you come to lab equipped with (a) your class text book, (b) this lab manual (possibly online) and (c) paper and pencil. You will usually need all three, so be sure to bring them each time. Late submissions: Your instructor will determine how and if late lab submissions are allowed, so be sure to check with your instructor. Be aware that these labs are created and ordered to enhance your success in CS150, and late execution of the labs results in a less than optimal learning scenario. Online Content: Your instructor will provide you with the location of online content to support this course, including reference materials including Java source files where applicable, links to relevant online content, instructional videos and the labs themselves.

Operating System Essentials 1. Ownership of files The most important concept to grasp from the beginning is how your files will be stored and managed, so let s start with the process of establishing how to log in with your user and password which will be used to manage file ownership. Picture the organization as follows: CS150 Lab PC 1 PC 2 File Server PC 3 As you work on the workstation in the lab, you determine whether the file will be stored on the machine in the lab, or on the file server. There are a few primary reasons that you want to store files on the files server. The images on the lab machines may be reset every time the machine is rebooted. This means that anything you store on this machine will be deleted. You want to be able to access your account files from any machine in the lab and from your dorm room. You want the files password protected and backed up to a secondary storage. Storing the files on the file server provides protection, global access and backup of your files. So store your files on the file server when possible. The name of the file server we will be using is Samba and can be found by clicking on 'Computer' in the Windows start menu, denoted as S:.

2. Logging In Be sure to read this entire section before attempting to log in. Your username and password will be provided to you via an email from the department system administrator if you do not have an account from a previous course offered by the department. This account is NOT the same account you use to read your cnu.edu email; instead it provides access to the departmental file server. Type your username and password and press the button labeled Log In. If you are unsuccessful in logging in, check for the following: A. Are you using the correct password? (It s not your cnu.edu email password!) B. Passwords are case-sensitive. For example, M is different from m. C. CAPS LOCK key should not be pressed in D. NUM LOCK key should not be pressed in E. Capital O looks similar to numeral 0. Are you tapping the correct key? F. Uppercase I looks similar to lower case L and numeral 1 (one). Are you tapping the correct key? If you have not been successful despite after making the above adjustments, see your instructor for assistance in determining your password. In some instances, students will simply need the password reset if it has been forgotten since last using the account, but your first inquiry for assistance should be with your lab instructor. In most cases the solutions is to email the department system administrator, and this might take a day or so to get a response. It is possible that the account can be reset while you are in the lab. If after all of these steps you still cannot successfully log in, the instructor will provide a generic username which has no password. There are many situations which might delay your obtaining the proper account information if we do not have correct email addresses or the most up-to-date registration. For the purpose of this lab, there is an alternative if you are having problems logging in. Simply read through the lab and use the alternatives

3. Accessing Server Storage Once you have logged on with your personal username and password, you will be able to access the file server. On Windows, this will be through a network drive (specifically as drive S:\). On Mac OSX, this will be your home directory. If you had to log in with the generic username, you will NOT have access to this server resource until your login problems are resolved, but you can still store your work on the c: drive or Mac Desktop and complete this lab. It is important that you read over this section and then revisit the section after you get your username and password. Graded Activities for Lab 1 The activities for lab are varied in nature. For the most part, you will perform an activity and show your instructor for approval. When the instructor verifies the correct

completion of that lab activity he/she will sign the grade sheet (at the end of this file), so have a copy of that sheet ready for your instructor s signature. Submit the signed sheet to your instructor when you are finished. The boxes in the margin on the left are an indication of the activities that will be graded and that correspond to the same questions on the grade sheet. Most of the subsequent labs will not utilize this manual grading process. The last question will be graded in a different manner and will be typical of the manner in which many of the lab exercises will be evaluated. Programs will most often be evaluated using the automatic grader, WebCAT. Details on the use of WebCAT are included in the lab, so be sure when you reach that point that you know how to verify successful completion of the activity as the WebCAT activities are not graded on the grade sheet.

Creating Programs using jedit If you are doing this on your own computer as opposed to the lab machines, see the instructions in the Appendix for setting up your computer before proceeding. 1. Text editors versus Word One of the core activities in programming is learning to use software tools for creating programs. You are likely familiar with using tools like Microsoft Word, but may or may not be familiar with a text editor such as the one you will use in this lab, jedit. Programs like Word store characters called control characters that define special formatting characteristics like list numbering, font styles and sizes, columns and figures as you see in this lab document. The programming that you will be doing requires the creation of text files which do not contain these control characters. If you try to open a Word document in a text editor like Windows notepad, you will easily see the characters which define the Word document formatting details. VIDEO A short video, Text file vs Word, explaining the issue is available at the web site. Setting up TextEdit for MacOSX: The TextEdit app can be used to edit formatted documents like Word, or it can be used as a plain text editor (i.e., no formatting, just text). You will set TextEdit to work by default as a plain text editor. Launch the TextEdit app. It is in the /Applications folder. Pull down the File menu and select New. Notice that a text window opens. At the top of that window is a formatting bar. Now pull down the TextEdit menu and select Preferences. At the top of the Preferences dialog box that appears, there are two tabs, New Document and Open and Save. New Document is selected by default. Click on the Plain Text radio button just below the tabs. Now select the tab Open and Save. Check the Ignore rich text commands in RTF files. The box for the HTML files should also be checked. Close the Preferences dialog box (click the red sphere at the left of the title bar). What did you just do? You turned TextEdit into a plain text editor. To see this, create another new file. Note that the text window that appears has NO formatting bar.

2. Using jedit to create a Java program. One could use Notepad (Windows) or TextEdit(Mac) to create Java programs, but there is a better program that can be used on either OS, is free to download, and is specifically tuned to create Java programs. Notepad/TextEdit is a reasonable alternative until you get jedit installed, but the rest of the lab refers to jedit. If you do not yet have jedit, just use the appropriate text editor for your OS. jedit is an application written in Java that will make it easier for you to create a Java program. There is a video on the course website to explain how to download and install jedit on your personal computer. VIDEO Watch the video Jedit Step 1. After you have watched the movie, create your first program named HelloWorld.java. The program should look like the following: public class HelloWorld { public static void main(string args[]) { System.out.println( HelloWorld ); } } Be sure to name it properly. The name of the file should be exactly HelloWorld.java where the use of the proper case is critical (i.e. helloworld.java will not work). If you have to use Notepad, when saving the file, put the entire name of the file in quotes or notepad will put.txt on the end of the file name, which is not compatible with Java. When saving the file, be very careful to observe where the file is saved. Windows users should store files on the S: drive, if possible. If you had to log in with the generic password, store the file on the C: drive in the Documents area. If you are still uncomfortable with directories, review the video and ask your instructor for help. Question 1 When you have completed the creation of HelloWorld.java and saved it, show your instructor.

Compiling and Running Your First Program Your first program will be compiled and executed using a command-line environment. VIDEO Watch the video Command Line Compiling-Running Java. Using Command Prompt in Windows and Mac OSX The command prompt is one of the oldest user interfaces used in computing. Although it is not as intuitive as graphical interfaces, it is not complicated to use either. The commands available for use in a command prompt are numerous and, if used correctly, quite powerful. Watching the video is the most efficient way to get started with this, SO BE SURE TO WATCH IT! The Windows and Mac OSX commands are very similar. In addition, Mac OSX is a UNIX system. If you know Linux, you know Mac OSX (well, almost). In our limited use of the command prompt, you will only use a few commands. Here are a few of the commands with which you should gain some familiarity. These are the only commands that you will need to learn. Task Windows Command Mac OSX Command List contents of current dir Ls directory Duplicate the contents of copy file1 file2 cp file1 file2 file1, naming the copy file2 Delete file1 del file1 rm file1 Changes current directory cd dir1 cd dir1 to the directory dir1 Compile the Java program javac file1.java javac file1.java file1.java Run the Java program file1 java file1 java file1

At this point, most students are fine with the process of building the file, but are confused with using the command line, even after watching the video. There are actually two aspects that you must understand. The first regards how to use the command line commands and the video along with some practice will quickly resolve your questions. The second issue is understanding how to use cd to get to the directory where the Java file was saved before compiling it. The second half of the Windows XP Directories video gives some examples of this and would be very helpful if this is still giving you issues. Question 2 Now compile and run your Hello World program. When you have completed the execution of the program, show your instructor. Next create a program named HolaMundo. Modify the HelloWorld program by making the following changes. 1. Change the name of the class to HolaMundo 2. Change the string printed from HelloWorld to HolaMundo 3. Change the name of the file to (what should the name be?) Question 3 Recompile and run the new program and show your instructor. VIDEO A video named Java and Integer Division should be viewed. If you want to run the program yourself, a copy of the code is available at the web site in the file Average3.java. Right-click/Save-As to store it on your account. Then compile and run it. Does this program correctly calculate the average? What major limitation does it have? Let s take a look at another version of this program. Look on the website for Average3Scanner. Compare the two programs. How is this new one different? How does it overcome the limitation of the first one? Try it out. Note that the source code on the web site is actually a.jpg (image) not a text file. You will have to enter the code yourself, as practice in the use of jedit, Javac and Java. Question 4 Recompile and run the program, then show your instructor where you have executed the Average3Scanner Java program. If you don t understand the advantage of having the user type the input, see your instructor and be sure to get some clarity on this before leaving the lab.

The last activity is to go through the process of submitting a file to the automated grader (WebCAT) for evaluation. WebCAT will be used extensively in subsequent labs and may be used by your lecturer, so use this activity to gain familiarity. In order to gain the benefit of the automated grader, your programs must adhere closely to the specifications given. Pay close attention to the name of the file expected and the format of the output requested. LAB 1 A Your instructor will set up a username and password, and it will emailed to you. The mail should should be received prior to the beginning of class, but if you have registered late or changed sections, see your instructor. WebCAT will be demonstrated in class. Following these instructions, take the HelloWorld.java file and submit it to WebCAT for grading. Upon submission, be sure to follow up and verify that the program ran correctly as this will be your primary mechanism for determining that you have completed lab activities in the future.

Student s Name ID Lab 1: Completion Table Question Completed Comments yes no 1 2 3 4 Instructor s signature Grade Don t forget to submit Lab 1 A to WebCAT.

Appendix 1. Understanding directories Whether you are using a remote file server or your local machine to store your programs, one needs a basic understanding of the organization of the file system of your OS. There are videos to help explain files and directories, using Windows directories as the point of focus. If you feel that you need further assistance, watch the instructional videos VIDEOS Files and Directories The C: Drive WindowsXpDirectories (pardon the noise that occurs at the beginning.. it will only last about one minute) These are only included as a resource to bring your level of understanding to a minimal level, so use your own discretion to determine what is necessary. Also remember that you have your instructor and student tutors to assist you. Windows VIDEO In the event that you need help with the notion of directories and drives in Windows, there are a number of videos on the course website to assist with this. View the videos depending on your current expertise. They are not lengthy, so if you have questions about whether to view them or not watch them! The important points to remember are: There are two locations where you might try to store files on the lab machines. a. C:\Documents and Settings\<your username>\ (Windows XP) Or b. C:\Users\<your username>\ My Documents\ (Vista and 7) i. This folder is on the local machine and is a less preferable place to save your files. c. S:\Windows\My Documents\ i. This folder is located on the file server (where you want to save your files). The reasons for using the S: drive are explained in the previous section on Ownership of Files. If you logged in with the generic username, you will NOT have access to the S: drive but if you were able to use your personal username, from the My

Computer icon you should be able to find drive S:\, your Network Drive, listed below the main computer drives. Everything on this drive is your account, but you should still be careful about how you use this space. Do not delete any of the files that are already in your account. Instead create new directories on this drive for storage and organization of your assignments. The files on the S: drive can only be accessed by you and are accessible from any of our department computers. If it is necessary to use the C: drive location (your account is not yet set up), understand that these files are very frequently deleted and also are readable and writable by anyone who logs on with that username. This is especially problematic if you had to log on as the generic user. Mac OSX Your home directory and all its contents are stored on the file server. If you want to store files on the server, just be sure the files are in your home directory. Most other directories will not be accessible to you, so if you want to store a file locally, your best bet is to use a thumb drive. Using the generic username If you use the generic account, you may need to save your results for subsequent use if you need to work on the lab after class. The simplest solution is to use your email account and mail the relevant files to yourself.

Appendix 2. Setting up your personal PC Setting up your personal computer The objective in setting up your machine for Java is to download and install two tools: Java development libraries and jedit for writing programs. Installing Java on your computer. There are a number of versions of Java available for download, but as long as you download a reasonably recent version, you should not have any conflict with the course activities. In case you have any questions in regard to this, check with your instructor to be sure that you have a recent version. If you own a Mac, your machine likely already has the updates appropriate for your version of the MacOS. You will still need to do the second step and install jedit. Questions regarding Java and MacOS can generally be answered at the following web site: http://developer.apple.com/java/faq/ If you own a PC, a Flash movie is available to guide you though this process. When you access the course web site (available from your instructor) to run the video, you may be asked if you want to install the Flash player, and if so, respond to do that installation also. Watching the video only takes about 5-6 minutes and the actual process of installation of Java takes a little longer. You can actually watch the video, and step through your own installation at the same time, pausing the movie when relevant. The video for Java installation can be found at the course web site and is named VIDEO Setting up Java Installing jedit on your computer. jedit is a powerful text editor that will be used to create Java programs. jedit requires the installation of Java, so be sure you have gone through the previous steps before installing jedit. All users will need to install jedit as it is not a default installation of any operating system. A video to assist with this process is available at the course web site and is named VIDEO Installing Jedit

Configuring your computer for Java. In order to properly configure your personal computer for using command-line Java, it is necessary to modify environment variables. Watch the following video for instructions on how to configure environment variables for Java on a PC. VIDEO Environment Variables You only need to perform the above activities once for your machine. These configurations have already been applied to the lab machine, so upon completion of these tasks your machine should perform identically to the lab machines. Transferring files between your personal PC and the file server. At this point, the easiest mechanism for transfer is to use a simple usb memory stick. You can also email yourself you lab files.