Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Fundamentals I Java Programming Spring 2009 XuanTung Hoang Lab 01.

Similar presentations


Presentation on theme: "Programming Fundamentals I Java Programming Spring 2009 XuanTung Hoang Lab 01."— Presentation transcript:

1 Programming Fundamentals I Java Programming Spring 2009 XuanTung Hoang tung_hx@icu.ac.kr Lab 01

2 XuanTung Hoang 2 Content Programming Environment Installation Lab Assignments:  Number Splitting  Circle’s Area and Circumference

3 XuanTung Hoang 3 Installation Install JDK  Download and install Java SE - JDK 6 from http://java.sun.com/javase/downloads/?intcmp=1281 http://java.sun.com/javase/downloads/?intcmp=1281 Faster link:  http://wine.icu.ac.kr/ice0124/jdk-6u12-windows-i586-p.exehttp://wine.icu.ac.kr/ice0124/jdk-6u12-windows-i586-p.exe  Updating PATH so that you can invoke javac and java from co mmand line Add ; C:\Program Files\Java\jdk1.6.0_12\bin to PATH environmental variable Install editor  Crimson Editor Download: http://www.crimsoneditor.comhttp://www.crimsoneditor.com  Vim Editor Download: http://www.vim.org/download.php#pchttp://www.vim.org/download.php#pc  Update PATH so that you can start your editor from command line You are not allowed to use IDE (e.g.: NetBean, Eclipse,…) to writ e your program during this course

4 XuanTung Hoang 4 Open command line (Start – Run – type “cmd” – Enter) Edit Hello.java (assume that you use Crimson Editor)  cedt Hello.java  Type/copy the following code public class Hello { public static void main( String[] args ) { System.out.println("Hello world\n"); }  Save the file Compile and run the sample application  Compile: javac Hello.java  Run: java Hello Testing Installation

5 XuanTung Hoang 5 I. Number Splitting Objectives:  Input/output with Scanner object  Modulus (%) operation for integers Requirements:  Create a class name NumberSplitting that has only main method (the pr ogram entry.)  In the main method, do the followings: Create an object of Scanner class Read a 5-digit integer from user (using nextInt() method of the created Scanner object) Split the 5-digit number into digits and print those digits to screen.  Refer to Addition.java in Lecture 2 as an example A sample output of the program execution… C> java NumberSplitting Enter 5-digit integer: 78368 Digits in 78368 are 7 8 3 6 8 C>

6 XuanTung Hoang 6 II. Circle’s area and circumference Objectives:  Input/output with Scanner object  Arithmetic operations (floating point numbers) Requirements:  Create a class that has only main method (the program entry)  In the main method, do the followings: Read the radius of a circle from user using nextDouble() of Scanner class  Remember to create Scanner object and store the input radius into a variable of appropriat e type  The usage of nextDouble() method is similar to nextInt() method Print out the corresponding diameter, area, and circumference of the circle A sample output of the program execution… Enter radius: 3.6 Diameter: 7.2 Area: 40.6944 Circumference: 22.608 C>

7 XuanTung Hoang 7 Submission and Report Due: 4 th March, mid-night Compress your source/class files into a ZIP file Name the zip file according with the following template:  StudentID_labNumber.zip Example: 20091004_lab1.zip Submit the file to TA  Email address: submit.hw.code@gmail.com  Subject: “StudentID_ICE0124_lab1” Example: 20061004_ICE0124_lab1


Download ppt "Programming Fundamentals I Java Programming Spring 2009 XuanTung Hoang Lab 01."

Similar presentations


Ads by Google