JAVA PROGRAMS WORKSHEET 4
1) Write a Java program to print the area and perimeter of
a rectangle.
Test Data:
Width = 5.5 Height = 8.5.
2) Write a Java program to print an American flag on the
screen.
Expected Output
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
==============================================
==============================================
==============================================
==============================================
==============================================
==============================================
3) Write a Java program to print a face.
Expected Output:
+"""""+
[| o o |]
| ^ |
| '-' |
+------+
4) Write a Java program to add two binary numbers.
Input Data:
Input first binary number: 10
Input second binary number: 11
5) Write a Java program to multiply two binary
numbers.
Input Data:
Input the first binary number: 10
Input the second binary number: 11
6) Write a Java program to print a pyramid.
Expected Output:
1
123
12345
1234567
123456789
7) Write a Java program to print a hollow diamond.
Expected Output:
1
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1