Java Basics
T ra in in g As s ig nmen t
Document Code 25e-BM/HR/HDCV/FSOFT
Version 1.1
Effective Date 20/05/2019
Hanoi, 05/2020
Training Assignments Java Basics (Automation Test) Issue/Revision: x/y
RECORD OF CHANGES
No Effective Date Change Description Reason Reviewer Approver
1 20/May/2020 Createw a new assignment Create new DieuNT1 VinhNV
25e-BM/HR/HDCV/FSOFT v1.1 Internal use 2/6
Training Assignments Java Basics (Automation Test) Issue/Revision: x/y
Contents
Java Flow Control ...............................................................................................................................................4
Objective .........................................................................................................................................................4
Business needs ..............................................................................................................................................4
Working requirements ....................................................................................................................................4
Product architecture .......................................................................................................................................4
Technologies ..................................................................................................................................................4
Stored Data ....................................................................................................................................................4
Exercise 1: ......................................................................................................................................................5
Exercise 2: ......................................................................................................................................................5
Exercise 3: ......................................................................................................................................................5
Exercise 4: ......................................................................................................................................................5
Exercise 5: ......................................................................................................................................................6
25e-BM/HR/HDCV/FSOFT v1.1 Internal use 3/6
Training Assignments Java Basics (Automation Test) Issue/Revision: x/y
CODE: Assignment01_Opt1
TYPE: Long
LOC: N/A
DURATION: 90 MINUTES
Java Flow Control
Objective
- Java if...else, Java switch Statement, Java for Loop, Java for-each Loop, Java while Loop, Java break
Statement, Java continue Statement
Business needs
- TBD
Working requirements
- Working environment: Eclipse IDE.
- Delivery: Source code, deployment and testing, reviewing evident packaged in a compress archive.
Product architecture
- N/A
Technologies
The product implements one or more technology:
- Java basics
- Java flow control
Stored Data
- N/A
25e-BM/HR/HDCV/FSOFT v1.1 Internal use 4/6
Training Assignments Java Basics (Automation Test) Issue/Revision: x/y
Exercise 1:
Write a Java program that reads a floating-point number and prints "zero" if the number is zero. Otherwise,
print "positive" or "negative". Add "small" if the absolute value of the number is less than 1, or "large" if it
exceeds 1,000,000.
Test Data
Input a number: 25
Expected Output :
Input value: 25
Positive number
Exercise 2:
Write a program in Java to display the cube of the number upto given an integer.
Test Data
Input number of terms : 4
Expected Output :
Number is : 1 and cube of 1 is : 1
Number is : 2 and cube of 2 is : 8
Number is : 3 and cube of 3 is : 27
Number is : 4 and cube of 4 is : 64
Exercise 3:
Write a program in Java to make such a pattern like right angle triangle with a number which will repeat a
number in a row.The pattern is as follows :
1
22
333
4444
Exercise 4:
Write a program to print out all Armstrong numbers between 1 and 500. If sum of cubes of each digit of the
number is equal to the number itself, then the number is called an Armstrong number.
For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )
25e-BM/HR/HDCV/FSOFT v1.1 Internal use 5/6
Training Assignments Java Basics (Automation Test) Issue/Revision: x/y
Exercise 5:
Compute the natural logarithm of 2, by adding up to n terms in the series
1 - 1/2 + 1/3 - 1/4 + 1/5 -... 1/n
where n is a positive integer and input by user.
-- THE END --
25e-BM/HR/HDCV/FSOFT v1.1 Internal use 6/6