Lesson Set 2 - CS 1136 Lab 2 Part 1: Creating a simple...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 1136 Lab 2 Part 1: Creating a simple program using Java IT IS VERY IMPORTANT THAT YOU DO EVERY STEP FROM LAB1. THE MOST IMPORTANT STEP WAS LEARNING HOW TO WRITE A PROGRAM, SAVE IT TO THE HARD DRIVE, AND COMPILE IT. Exercise 1: 1. Load the program you have selected to create Java source code and create a new Java source file. Name the file “Lab2 _Ex1.java . Type in the following program. // CS1136 Lab 02 Exercise 1 // Type your name here public class Lab2_Ex1 { public static void main (String [] args) { int a = 25; int b = 10; System.out.println(" a is “ + a + “ and b is “ + b); System.exit(0); } } 2. Save the program in your directory on the hard drive. 3. Compile your program. 4. If there are any errors in your program code, correct them and recompile the program. 5. Execute your program. 6. Save your output. 7. Upload and submit your .java and output files to eLearning. Part 2: Introduction to Using Various Identifiers and Arithmetic Operators We name things such as variables, constants, and functions by giving them an identifier. A Java identifier is made up of letters, numbers and underscores but may not begin with a number. Remember that Java is case-sensitive, meaning that NUM is a different identifier than num or even Num .
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Let's examine the following Java program: 1. //Program Lunch calculates the number of calories in a 2. //cheese sandwich. 3.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/30/2012 for the course CS 1136 taught by Professor N/a during the Fall '08 term at University of Texas at Dallas, Richardson.

Page1 / 3

Lesson Set 2 - CS 1136 Lab 2 Part 1: Creating a simple...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online