Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 25 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
25
Dung lượng
1,16 MB
Nội dung
Lab Guide Lab version:1.0.0 Last updated:12/27/2013 Page Overview In this lab, you will learn all the necessary steps for installing a environment development for Java You will start with some basic of Java programming, write a simple program to understand some basic features of Java Objectives Once you have completed this lab: You will understand how to use for statement You will understand how to use while and while statement You will able to use array and string in Java You will understand how to sort a array You will understand how to use nested loop in Java Exercises This Hands-On Lab is comprised by the following exercises: Oddevensum Compute Pi Do While Statement Array Loops And Conditional Statement Nested Loop Break Label Continue Label Array Sort Reverse String Array Of String Page Cozalozawoza Fibonacci Special Characters And Escape Sequences Print Pattern Using Nested-Loop Print Number Using Nested-Loop Pascal Triangle Random Array Gcd Program Estimated time to complete this lab: hours in class and hours at home Page Index EXERCISE 1: ODDEVENSUM Task - Create a OddEvenSum Classs Task - Write code for OddEvenSum Class Task - Execute your program EXERCISE 2: COMPUTE PI Task - Create a ComputePI Classs Task - Write code for ComputePI Class Task - Execute your program EXERCISE 3: DO WHILE STATEMENT Task - Create a DoWhile Classs Task - Write code for DoWhile Class Task - Execute your program EXERCISE 4: 10 ARRAY 10 Task - Create a ArrayTest class 10 Task - Write your code inside the main() method 10 Task - Execute your program 11 EXERCISE 5: LOOPS AND CONDITIONAL STATEMENT 11 Task - Create a PrimeList class 11 Task - Write your code inside the main() method 12 Task - Execute your program 13 EXERCISE 6: NESTED LOOP 13 Task - Create a PrintPattern class 13 Task - Write code inside the main() method 14 Task - Execute your program 15 Page EXERCISE 7: BREAK LABEL 15 Task - Create a JavaGoto class 15 Task - Write code for JavaGoto class 15 Task - Execute your program 16 EXERCISE 8: CONTINUE LABEL 16 Task - Create a JavaGoto class 16 Task - Write code for ContinueLabel class 16 Task - Execute your program 17 EXERCISE 9: ARRAY SORT 17 Task - Create a ArrayBubleSort class 17 Task - Write code for ArrayBubleSort class 17 Task - Execute your program 18 EXERCISE 10: REVERSE STRING 18 Task - Create a ReverseString class 18 Task - Write code for ReverseString class 19 Task - Execute your program 19 EXERCISE 11: ARRAY OF STRING 19 Task - Create a Dayofweek class 20 Task - Write code for Dayofweek class 20 Task - Execute your program 20 EXERCISE 12: NESTED LOOP 20 EXERCISE 13: NESTED LOOP 21 EXERCISE 14: COZALOZAWOZA 21 EXERCISE 15: FIBONACCI 22 EXERCISE 16: SPECIAL CHARACTERS AND ESCAPE SEQUENCES 22 Page EXERCISE 17: PRINT PATTERN USING NESTED-LOOP 22 EXERCISE 18: PRINT NUMBER USING NESTED-LOOP 23 EXERCISE 19: PASCAL TRIANGLE 24 EXERCISE 20: RANDOM ARRAY 24 EXERCISE 21: GCD PROGRAM 24 Page Next Step Exercise 1: OddEvenSum Task - Create a OddEvenSum Classs In the "Package Explorer" (left panel) ⇒ Right-click on your Project (or use the "File" menu) ⇒ New ⇒ Class The "New Java Class" dialog pops up In "Name" field, enter "OddEvenSum " Check "public static void main(String[] args)" box Click "Finish" Task - Write code for OddEvenSum Class public class OddEvenSum { public static void main(String[] args) { int lowerbound = 1; int upperbound = 10; int sumOdd = 0; int sumEven = 0; for (int number = lowerbound; number