1 / 7

Programming Fundamentals I Java Programming Spring 2009

Programming Fundamentals I Java Programming Spring 2009. XuanTung Hoang tung_hx@icu.ac.kr. Lab 01. Content. Programming Environment Installation Lab Assignments: Number Splitting Circle’s Area and Circumference. Installation. Install JDK

oneida
Télécharger la présentation

Programming Fundamentals I Java Programming Spring 2009

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Content • Programming Environment Installation • Lab Assignments: • Number Splitting • Circle’s Area and Circumference

  3. Installation • Install JDK • Download and install Java SE - JDK 6 from http://java.sun.com/javase/downloads/?intcmp=1281 • Faster link: • http://wine.icu.ac.kr/ice0124/jdk-6u12-windows-i586-p.exe • Updating PATH so that you can invoke javac and java from command line • Add ; C:\Program Files\Java\jdk1.6.0_12\bin to PATH environmental variable • Install editor • Crimson Editor • Download: http://www.crimsoneditor.com • Vim Editor • Download: http://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 write your program during this course

  4. Testing Installation • 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

  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 program 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. 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 appropriate 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. Submission and Report • Due: 4th 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

More Related