Programming Assignment I
Programming Assignment I
2. Write a java program that displays your name and address on the screen as if it
were a letter. Your output should look something like that below.
+-------------------------------------------------------------------------------------+
| #### |
| #### |
| #### |
|
| Biswanath Dash|
| H.N:109, Baramunda|
| Bhubaneswar|
+--------------------------------------------------------------------------------------+
Page 1 of 4
3. Write a java program to display your initials on the screen in block letters as
shown. For example the name Tapan Kumar
TTTTTTTTTT KK KK
TT KK KK
TT KK KK
TT KK
TT KK KK
TT KK KK
TT KK KK
4. Write a java program to print an equilateral triangle using star ' * '.
*
**
***
****
*****
5. Write a java program that stores your Regd. No and year of admission into two
variables, and displays their values on the screen.
My Regd. No is 1961020012 and I have taken admission in MCA In 2023.
6. Let we have two values 113, 2.71828. Then, declare two different variables to hold
the given values. Write the java program to display the values of these two variables
on the screen, one per line.
This is room # 113
e is close to 2.71828
Page 2 of 4
7. Write a java program to exchange the values of two variables of integer type A and
B using third temporary variable C.
8. Write a java program to exchange the values of two variables of integer type A and
B without using third temporary variable.
9. What do each of the following print?
a. System.out.println(2 + "bc");
b. System.out.println(2 + 3 + "bc");
c. System.out.println((2+3) + "bc");
d. System.out.println("bc" + (2+3));
e. System.out.println("bc" + 2 + 3);
Page 3 of 4
f. System.out.println(4*a);
12. Suppose that a variable a is declared as double a = 3.14159. What do each of the
following print?
a. System.out.println(a);
b. System.out.println(a+1);
c. System.out.println(8/(int) a);
d. System.out.println(8/a);
e. System.out.println((int) (8/a));
13. Assume a string variable ruler1 contains “1” initially i.e. String ruler1=”1” . Write
a java program to print the following output using string concatenation. (You can take
extra string variables)
1
121
1213121
121312141213121
Page 4 of 4