<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Introduction to Java - CSCI 151: Data Structures</title><link>https://cs.oberlin.edu/~cs151/lab-1/index.html</link><description>Lab 1 Welcome to your first CSCI 151 lab! Hopefully you’ve already completed Lab 0. If not, head over there now before continuing on with this lab. Otherwise, let’s get started with Lab 1. This lab is all about learning how to write our first Java programs!
Goals Create your first Java programs Use Visual Studio Code as an integrated development environment (IDE) Compiling and run programs using the Terminal Practice using git and GitHub Create a simple drawing program, a guessing game, and a program for data science We will begin every lab by creating a copy of the assignment in GitHub Classroom. You can do so by clicking on this link: Accept Assignment</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 05 Jul 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://cs.oberlin.edu/~cs151/lab-1/index.xml" rel="self" type="application/rss+xml"/><item><title>Using the Lab Machines</title><link>https://cs.oberlin.edu/~cs151/lab-1/w-part-2/index.html</link><pubDate>Wed, 05 Jul 2023 00:00:00 +0000</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-1/w-part-2/index.html</guid><description>In this course, you will be using the Computer Science lab computers in King 135/137 and King 201 to complete your work. These computers are set up to have everything you need to write and test code in Java.
The lab computers are set up to have two operating systems: Linux and Windows. In this course, you will be using Linux. If you sit at a computer and it is currently logged in to Windows, you should reboot the computer, and choose Linux when it asks what Operating System you want by selecting the “Ubuntu” option (which should be the second from the top).</description></item><item><title>Using Git and GitHub</title><link>https://cs.oberlin.edu/~cs151/lab-1/w-part-3/index.html</link><pubDate>Wed, 05 Jul 2023 00:00:00 +0000</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-1/w-part-3/index.html</guid><description>Setting Up GitHub We will be using GitHub to distribute the starter files for your labs, and for you to submit your work. GitHub is a widely used platform to store code that uses the Git protocol to save all changes to your code. The great thing about using Git is that it allows you to go back to earlier saved versions of your code if you make a mistake.
README You should save your files back to git whenever you make progress on part of the lab assignment, and especially before you leave the lab.</description></item><item><title>Using Visual Studio Code</title><link>https://cs.oberlin.edu/~cs151/lab-1/w-part-4/index.html</link><pubDate>Wed, 05 Jul 2023 00:00:00 +0000</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-1/w-part-4/index.html</guid><description>You will be using Visual Studio Code to edit your files. Open VS Code by again clicking on the “nine dots” icon in the bottom left of your screen, typing “visual” in the search box that appears at the top, then click on the “Visual Studio Code” program, as shown in this screenshot: Installing the Extension Pack for Java To help support our development this semester, we will need to install the Extension Pack for Java in VS Code. To do so, first click on the fifth icon down on the left side of your VS Code window that looks like:</description></item><item><title>Hello World</title><link>https://cs.oberlin.edu/~cs151/lab-1/w-part-5/index.html</link><pubDate>Wed, 05 Jul 2023 00:00:00 +0000</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-1/w-part-5/index.html</guid><description>In Visual Studio Code, open HelloWorld.java. Take a few minutes to look the code over and discuss it with a neighbor. You should notice some comments, a class declaration, a main function, and a line of code inside the main function. What do each of these parts do?
Now we’ll run the code. Unlike Python, Java is a compiled language, which means that first we need to compile our file into java bytecode, then run it. The command to compile a java file is javac, and the command to run it is java. In your Terminal window, type</description></item><item><title>Command Line Arguments</title><link>https://cs.oberlin.edu/~cs151/lab-1/w-part-6/index.html</link><pubDate>Wed, 05 Jul 2023 00:00:00 +0000</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-1/w-part-6/index.html</guid><description>Command line arguments are a way for you to pass information to your program when you run it. You simply type the information you want to give your program after the name of your java program when you run. So to pass the arguments “hello” “world” to the class Args, you would type:
java Args hello world This is how we will run Java files for the rest of the semester.</description></item><item><title>Scanning Strings</title><link>https://cs.oberlin.edu/~cs151/lab-1/w-part-7/index.html</link><pubDate>Wed, 05 Jul 2023 00:00:00 +0000</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-1/w-part-7/index.html</guid><description>In VS Code, open the file Numbers.java Above the public class Numbers line, add the line:
import java.util.Scanner; Inside main, add the code:
String numbers = "86 75 309"; Scanner scanner = new Scanner(numbers); while (scanner.hasNextInt()) { int num = scanner.nextInt(); System.out.println(num); } scanner.close(); With your partner, predict what will happen when you run this code. Compile and run the code using the Terminal.
Did it match what you expected?</description></item><item><title>Scanning Files</title><link>https://cs.oberlin.edu/~cs151/lab-1/w-part-8/index.html</link><pubDate>Wed, 05 Jul 2023 00:00:00 +0000</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-1/w-part-8/index.html</guid><description>Reading the Documentation First, let’s look at the Java documentation for the Scanner class. Java has great documentation for all its built-in libraries, and it is the first place you should look when you are trying to figure out how to do something. Take a look at the Scanner documentation here.
There’s a lot of information on that page, but what you should be most interested in is the writeup at the top about how to use Scanner, and then the list of all the Scanner methods. Look at the documentation for hasNext() and next(). Note that they behave like hasNextInt() and nextInt(), except they read and return strings. You should also notice that Scanner has hasNext and next methods for a variety of types.</description></item><item><title>Building Pyramids</title><link>https://cs.oberlin.edu/~cs151/lab-1/l-part-1/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-1/l-part-1/index.html</guid><description>Program Overview For your first program, you will create a Java program that draws a pyramid out of * characters that has a height determined by the user. This will practice using for loops, System.out.print and System.out.println statements, and getting input from the user through the command line.
For example, if the user wants a pyramid of height 5, a run of your program like:
java Pyramid 5 should create output that looks like:</description></item><item><title>What Number am I Thinking of?</title><link>https://cs.oberlin.edu/~cs151/lab-1/l-part-2/index.html</link><pubDate>Fri, 06 Aug 2021 18:53:30 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-1/l-part-2/index.html</guid><description>Program Overview For your second program, you will create a numeric guessing game. This will practice using while loops, parsing user input from the Terminal while the program is running using a Scanner, and Exception handling.
In your program, the computer will pick a random number between 1 and 1000, and then the user will try to guess what it is until they guess the correct number. Each time the user guesses incorrectly, the program should provide a hint that the guessed number is either too high or too low. For example, a run of the program might look like:</description></item><item><title>Summer School Data Science</title><link>https://cs.oberlin.edu/~cs151/lab-1/l-part-3/index.html</link><pubDate>Fri, 06 Aug 2021 19:43:41 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-1/l-part-3/index.html</guid><description>Program Overview For your final program, we will be creating a program that analyzes data. This will practice using Scanner objects to both read data from file and parse data within the file, calculate statistics from data, and demonstrate how computer programs can be used to aid in answering research questions for data science.
We will be using a data set of anonymized Teaching Assistant evaluation scores collected by the Statistics Department of the University of Wisconsin-Madison. Our research question for this dataset is:</description></item><item><title>Wrap Up</title><link>https://cs.oberlin.edu/~cs151/lab-1/wrap-up/index.html</link><pubDate>Fri, 06 Aug 2021 20:21:56 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-1/wrap-up/index.html</guid><description>Congratulations! You have now created several Java programs and completed your first lab of the semester!
Filling Out the README.md The final task for every lab is to edit the README file in the lab assignment repository. Each week, you’ll be asked to answer three questions regarding collaboration, time spent on the lab, and the Honor Code.
A reminder to make sure you have consulted the Honor Code policy in the course syllabus for information about how to sign the Honor Code and about acceptable collaboration in CSCI 151. Your instructor is also happy to answer any questions about the Honor Code – just let us know.</description></item></channel></rss>