CS160: Foundations in Programming: Summmer 2016
Recitation R0 - Introduction to Programming
The goals of this lab are as follows:
- Login to department systems
- Discover the class website
- Learn to run Linux applications and the Linux operating system
- Get familiar with Linux commands
- Get Eclipse up and running
- Write a very simple Java program
- Show you how to checkin your programs
- Learn about preliminary testing
Raise your hand if you cannot login!
- Login to the machine using your electronic ID (same username that you use for RamWeb).
- The password should be your student ID (the nine digit number on your RamCard).
- The TA will show you how to change your password.
- Use the
passwd command to change your password.
- We recommend changing it to your RamWeb password.
- man commandName - manual for commandName
- cp originalFileName newFileName - used to copy files (we will use this frequently for your quizzes and assignments).
- mv fileName directoryPath - moves a file to the specified directory
- cd directoryName - changes your location to the specified directory
- mkdir directoryName - makes a directory called directoryName
- rm fileName - removes a file called fileName
- rmdir directoryName - removes an EMPTY directory called directoryName
- ls - lists files and directories in your current folder
- cat fileName - prints the contents of fileName to the terminal
- diff fileName1 fileName2 - compares fileName1 and fileName2. NOTE: if the files are the same, then the terminal will print nothing, otherwise, it will print where and what is different.
- pwd - prints working directory (where you are currently in your file system)
Linux Operating System
- . - current directory
- ~ - home directory
- .. - parent directory
- Open a terminal window by going to the upper left corner of the screen, then select "Activities" and then "Applications"
- change directories to your "Documents" folder
- make a directory in your your current directory called Practice
- change directories into your Practice directory, open "gedit" by typing gedit &
- type your first and last name. Save the file as file0 in your Practice directory
- copy file0 to a new file called newFile
- type pwd into the terminal. What is printed? What does it mean?
- use the diff command to see if file0 and newFile are the same. What do you expect to happen?
- open "gedit" again by typing gedit newFile & enter a fun fact about yourself under your first and last name
- use the diff command again to see if file0 and newFile are the same
- use cat to print the contents of newFile
- remove file0
- move newFile to your home directory
- change directories to your home directory
- list what is in that directory
- Start your preferred internet browser and type in the url www.cs.colostate.edu/~cs160.
- Note: the semester that appears as part of the url!
- Look at the syllabus and progress pages.
- Find the lab instructions for today.
- Open another tab and type in the url http://info.canvas.colostate.edu/login.aspx.
- Login to Canvas using your EID and password and make sure you can see CS160.
- Your TA will show you how to launch applications and add them to the task bar.
- Run firefox, gedit, file manager, and a terminal.
- The terminal command brings up a window where you can type in Linux commands
- Note: this is similar to using the DOS command prompt on Windows.
Eclipse makes programming easier by compiling and running your programs in a single step.
Your TA will go over setting up Eclipse and your workspace.
- To start Eclipse, open a terminal window and type eclipse.sh.
- Note: you must do this every time you launch Eclipse.
- Close the Eclipse welcome window.
Adding a Header to New Files
Creating a Header Shortcut
Your TA will guide you in creating a project called R0, copying the Java file through the terminal, and using the shortcut in eclipse to insert your header.
NOTE: unless otherwise specified print with a new line.
- Create a new project using the File→New→Project, and name it R0.
- Your TA will show you how to copy R0.java into your R0 src folder in Eclipse from the terminal.
- At the top of the file hit Ctrl-Space on your keyboard and select header
- Click on the green "Play" shaped button on the toolbar and you should see 2 lines of output in the Console window at the bottom of the window.
- Follow the instructions exactly to finish the rest of the recitation.
- On the first line of output, print the string "Computer Science is great!".
- On the second line of output, print the string "Java Programming can be fun.".
- On the third line of output, print your last name, a comma followed by a space, and your first name.
- On the fourth line of output, print your major or "Undeclared".
- On the fifth line of output, print the name of this class "CS160 Foundations in Programming".
- On the sixth line of output, print the due date of this assignment in the format shown below.
- On the seventh line, print a sentence that explains why you are taking this class.
- Some additional directions for the seventh line, as follows:
- Must start with a capital letter.
- Must end with a period.
- Must be between 50 and 70 characters total, including white space.
Your program should print seven lines, and should match the output shown below, except
as described here. You must print exactly the strings shown on the first and second lines.
Spelling errors, incorrect capitalization, extra or missing white space and any other difference
will cause a failure. The third line will have your name instead of mine. The fourth line will
not be checked, but must be present. The fifth and sixth lines must have exactly the strings shown.
The seventh line must follow the specification given above. See the grading criteria below for
Computer Science is great!
Java Programming can be fun.
CS160 Foundations in Programming
I am in this class because programming is a lot of fun.
Your program must meet the following specifications:
- The name of the source code file must be exactly R0.java.
- Name the file exactly - upper and lower case matters!
- Header at the top as shown above.
Submit your program to the Checkin tab on the course website, as you were shown by your TA. For detailed information on Eclipse,
check out the Eclipse website.
- 100 points for perfect submission.
- 0 points for no submission, will not compile, submitted class file, etc.
- testCompile: checks that program compiles. (10 points)
- testComment: checks the comment block at top of program. (10 points)
- test1: checks first line of output. (5 points)
- test2: checks second line of output. (5 points)
- test3: checks third line of output. (5 points)
- test4: checks fourth line of output. (5 points)
- test5: checks fifth line of output. (10 points)
- test6: checks sixth line of output. (10 points)
- test7: checks that seventh line starts with a capital letter. (10 points)
- test8: checks that seventh line ends with a period. (10 points)
- test9: checks that seventh line has between 50 and 70 characters. (10 points)
- test10: checks that program has exactly seven lines of output. (10 points)
© 2016 CS160 Colorado State University. All Rights Reserved.