Java File
Java File
of
Java Programming Lab (PCS-408)
Submitted in partial fulfillment of the requirement for the IV semester
Bachelor of Technology
By
Ajay Rawat
2261076
Under the Guidance of
Ms. Kashish Mirza
Lecturer
Department of CSE
The term work of Java Programming Lab , being submitted by Ajay Rawat
D/O Mr. Surendra Singh Rawat University Roll Number 2261076 to Graphic
Era Hill University, Bhimtal Campus for the award of bona fide work carried
out by him. He has worked under my guidance and supervision and fulfilled
(Lecturer, Dept. of CSE, GEHU Bhimtal Campus) for allowing me to carry out
this practical work under his excellent and optimistic supervision. This has all
been possible due to his novel inspiration, able guidance and useful suggestions
I want to extend thanks to our President Prof. (Dr.) Kamal Ghanshala for
providing us all infrastructure and facilities to work in need without which this
(AJAY RAWAT)
University Roll Number: 2261076
INDEX PAGE
S.no. Question Date Sign
01 Write a java program to print “Hello world”
02 Write a java program to add two numbers
03 Write a java program to add two numbers by taking input from user
04 Write a java program to print the difference of two numbers
05 Write a java program to print the difference of two numbers by taking
input from user
06 Write a java program to print a pattern:
*
**
***
****
*****
07 Write a java program to check weather the given number is even or
odd
08 Write a java program to print the string by taking input from user
09 Write a java program to demonstrate switch case statement:
Case 1: “Graphic Era Bhimtal”
Case 2: “Graphic Era Haldwani”
Case 3: “Graphic Era Dehradun”
Case 4: “Graphic Era Deemed To Be University”
default: “GEHU”
10 Write a java program to print two statements in different lines by line
changing method
11 Write a java program to print “hello world” 100 times by using for
loop
12 Write a java program to print natural numbers up to 10
(i) in horizontal form,
(ii) in vertical form by using for loop:
Eg: 1 2 3 4 ….
Eg: 1
2
3..
13 Write a java program to print table of a number by taking input from
user using do while loop
14 Write a java program to print natural numbers up to 11 by using while
loop
15 Write a java program to print the pattern, using nested loop:
****
****
****
****
16 Write a java program to take input as a command line argument.
Your name,course, university roll no and semester. Display the
information.
Name: University Roll No: Course: Semester:
17 Using the switch statement, write a menu-driven program to
calculate thematurity amount of a bank deposit.
The user is given the following options:
(i) Term Deposit
(ii) Recurring Deposit
For option (i) accept Principal (p), rate of interest (r) and time period
in years (n). Calculate and output the maturity amount (a) receivable
using the formulaa = p[1 + r / 100]n.
For option (ii) accept monthly installment (p), rate of interest (r) and
time periodin months (n). Calculate and output the maturity amount
(a) receivable using the formula a = p * n + p * n(n + 1) / 2 * r / 100 *
1 / 12. For an incorrect option,an appropriate error message should be
displayed.
[ Use Scanner Class to take input]
Output 1:
3748261
Input 2:
4
1432
Output 2: 1 4 2 3
21 The problem to rearrange positive and negative numbers in an array .
Method: This approach moves all negative numbers to the beginning
and positive numbers to the end but changes the order of appearance
of the elements of the array.
Steps:
Test case:
• Input: 1 -1 2 -2 3 -3
• Output: -1 -2 -3 1 3 2
22 Program to find the saddle point coordinates in a given matrix. A
saddle pointis an element of the matrix, which is the minimum
element in its row and the
maximum in its column.
For example, consider the matrix given
below Mat [3][3]1 2 3
456
789
Here, 7 is the saddle point because it is the minimum element in its
row andmaximum element in its column.
Steps to find the saddle point coordinates in a given matrix.
Import java.util.*;
class HelloWorld{
public static void main(String args[])
{
System.out.println(“Hello World”);
}
}