0% found this document useful (0 votes)
4 views

Assignment 2

Uploaded by

ameerayman38
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Assignment 2

Uploaded by

ameerayman38
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

OOP Java | Assignment 2 | 1st Semester 2023/2024

Instructor: Laith W. AL Shehab

Assignment 2

1. Write a Java program to print 'Hello' on screen and then print your name
on a separate line.
Expected Output :
Hello
Laith AL shehab

2. Write a Java program to print the sum of two numbers.


Test Data:
74 + 36
Expected Output :
110

3. Write a Java program to print the result of the following operations.

Test Data:
a. -5 + 8 * 6
b. (55+9) % 9
c. 20 + -3*5 / 8
d. 5 + 15 / 3 * 2 - 8 % 3
Expected Output :
43
1
19
13

4. Write a Java program to convert a decimal number to binary number.


Input Data:
Input a Decimal Number : 5
Expected Output
Binary number is: 101
5. Write a Java program to convert a binary number to decimal number.

Input Data:
Input a binary number: 100
Expected Output
Decimal Number: 4
6. Write a Java program to print the contents of a two-dimensional Boolean
array where t will represent true and f will represent false.

Sample array:
array = {{true, false, true},
{false, true, false}};
Expected Output :
tft
ftf

7. Write a Java program to find the k smallest elements in a given array.


Elements in the array can be in any order.

Expected Output:
Original Array:
[1, 4, 17, 7, 25, 3, 100]
3 largest elements of the said array are:
100 25 17

Submission:
You must put all your work (the Java Application NetBeans project) in one Folder named
based on your Name and ID followed by the Homework Number. Then compress this
folder into one .rar or .zip file and upload it into the MEU e-learning system.

You might also like