Java Lab Exercise 1 Control STMT
Java Lab Exercise 1 Control STMT
IE1 - Write a Java program to display a String HELLO WORLD and WELCOME TO JAVA
PROGRAMMING.
IE2 Write a Java program to display a String CHEERS!!!! for 10 times.
IE3 Write a Java program to display your first name, last name, age and address.
1.
a) Display the output as below :( 1+2+3+4+5+6+7+8+9+10)
Sum of the above numbers =55
b)Write a program to display the sum of first ten even natural numbers
(2+4+6+8+10+12+14+16+18+20).
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
A
A B A
A B C B A
A B C D C B A
A B C D E D C B A
*
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
A
A A
A B B A
A B C C B A
A B C D D C B A
A B C D E E D C B A
A
A B
A B C
A B C D
A B C D E
6) Print a triangular multiplication table as shown below:
0
0 2
0 3 6
0 4 8 12
0 5 10 15 20
0 6 12 18 24 30
0 7 14 21 28 35 42
*****
#####
*****
#####
*****
10) Write a program to swap two numbers without using any temporary variable.
11) Write a program to convert 69F into its equivalent centigrade temperature.
(centigrade=(fht 32) * 5/9
13) Write a program to calculate the sum of the odd integers between 1 and 99 using for
loop.
14) Write a Java program to display the addition, subtraction, multiplication and division
of two floating point numbers.
15) Write a Java program to display the division of the student based on the marks scored
in 5 subjects using if condition.
First Division ------- Equal or above 60%
Second Division ------- Equal or Greater than 45% and Less than 60%
Third Division ------- Equal or Greater than 33% and less than 45%
Fail ------- Less than 33%
Given the marks in three subjects, write a program to process the applications (with
multiple objects) to list the eligible candidates.
17) Write a program using if-else if and switch statements to display the season of a month
based on the following:
Month Season
12, 1, 2 Winter
3, 4, 5 Spring
6, 7, 8 Summer
9, 10, 11 Autumn
Any other Bogus Month
18) Accept the input by the user through Command Line Argument as m and perform the
following
a) Reverse the digits of the number m Eg. 123456 Result: 654321
b) Compute and print a table of factorials for any given m
c) Calculate and print the first m Fibonacci numbers.
19) Write a Java Program to verify that the string passed through command line argument is a
palindrome or not.
20) Write a Java program that accepts three integers as input from the user, which are
lengths of the side of the rectangle. Your program should display the type of rectangle
(Equilateral, right angled, isosceles triangle, scalene triangle)
21) Write a program to accept three command line arguments from the user and to display
it in sorted order.
22) Write a program to accept a String and display each character of the String separately.
A character should not be repeated. Along with this, display the number of times the
character appears.
23) Write a class Rectangle with overloaded constructors. In the first constructor accept
only one parameter and the code for the constructor should display that It is a Square
and calculate the area. The second constructor should take two parameters and display It
is a Rectangle and calculate the area