Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Programming Assignment I

The document outlines a programming assignment consisting of various tasks to be completed in Java. These tasks include displaying messages, formatting output as a letter, printing initials in block letters, creating shapes with stars, and manipulating variables. Additionally, it includes questions about the output of specific Java statements and operations involving integer and double types.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Programming Assignment I

The document outlines a programming assignment consisting of various tasks to be completed in Java. These tasks include displaying messages, formatting output as a letter, printing initials in block letters, creating shapes with stars, and manipulating variables. Additionally, it includes questions about the output of specific Java statements and operations involving integer and double types.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Programming Assignment-I

(Simple Output Statements)


1. Write a java program to display following messages.
Hello World!
Hello Again
I like typing this.
This is fun.
Yay! Printing.
I'd much rather you 'not'.
I "said" do not touch this.

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);

10. What do each of the following print?


a. System.out.println('b');
b. System.out.println('b' + 'c');
c. System.out.println((char) ('a' + 4));

11. Suppose that a variable a is declared as int a = 2147483647


(or equivalently, Integer.MAX_VALUE ). What do each of the following print?
a. System.out.println(a);
b. System.out.println(a+1);
c. System.out.println(2-a);
d. System.out.println(-2-a);
e. System.out.println(2*a);

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

You might also like