Summer 2021: Programming in Java Lab

From MKWiki
Jump to navigation Jump to search

Resources

  • Basic building block(syntax) tutorial from cs.princeton.edu
  • Basic Programs List

Lab 1: Getting Started ( week of 04th January 2021 )

Q. NO. Program Lab Exercise No. Remarks
1 WAP to find the sum of any number of integers entered as command line arguments. Practice Set No. 1
2 WAP to find whether the given number is even or odd. Practice Set No. 2
3 WAP to find the factorial of a given number. Practice Set No. 3
4 WAP to check whether the given number is prime or not. Practice Set No. 4
5 WAP to print the following pattern using nested for loop:
    *
    *  *
    *  *  *
    *  *  *  * 
Practice Set No. 5

Lab 2: ( week of 11th January 2021 )

Q. NO. Program Lab Exercise No. Remarks
1 WAP to find the sum of digits of a given number. [ Sample input: 12345, output:15 ] Practice Set No. 1
2 WAP to reverse the digits of a given number. [ Sample input: 12345, output:54321 ] Practice Set No. 2
3 Write program to print the kth digit from last. [ Sample input 23617 and k=4 output 3 ] Practice Set No. 3

Lab 3: ( week of 18th January 2021 )

Q. NO. Program Lab Exercise No. Remarks
1 WAP to find the largest of n natural numbers. Practice Set No. 1
2 WAP to print the sum and product of digits of an Integer and reverse the Integer. Practice Set No. 2
3 Write a menu driven program for following:

(a) Display a Fibonacci series
(b) ComputeFactorial of a number
(c) WAP to check whether a given number is odd or even.
(d) WAP to check whether a given string is palindrome or not.

Practice Set No. 3

Lab 4: ( week of 25th January 2021 )

Q. NO. Program Lab Exercise No. Remarks
1 Write a program to create an array of 10 integers. Accept values from the user in that array. Input another number from the user and find out how many numbers are equal to the number passed, how many are greater and how many are less than the number passed. Lab Exercise No. 13
2 Write a program that will prompt the user for a list of 5 prices. Compute the average of the prices and find out all the prices that are higher than the calculated average. Lab Exercise No. 14
3 Write a program to input N numbers in an array and print out the Armstrong numbers from the set. Practice Set No. 1
4 Write a program for following matrix operations:

(a) Input the elements of Matrices from user
(b) Addition of two matrices
(c) Multiplication of two matrices
(d) Transpose of a Matrix.

Practice Set No. 2

Lab 5: ( week of 01st February 2021 )

Q. NO. Program Lab Exercise No. Remarks
1 5-6 Programs based on Lecture 3. Practice Set Lect(3)

Lab 6: ( week of 08th February 2021 )

Q. NO. Program Lab Exercise No. Remarks
1 4-5 Programs based on Lecture 4. Practice Set Lect(4)

Lab 7,8,9: ( week of 15th,22nd February & 1st March )

Q. NO. Program Lab Exercise No. Remarks
1 Complete all the previous exercises. ( Lab01-Lab06 )

Final Lab: ( week of 05th April )

Q. NO. Program Lab Exercise No. Remarks
1 Design a class named Car, having registration number, model and engine as its private members. Here engine is an object of a class called Engine with the private members:Chassis number and make. Define a suitable constructor of Car and override toString( ) method to print the details of a car. Assume appropriate data types for the instance members of the classes. Write a Java program to test the above class. Lab Exercise No. 15