Skip to content

Harshal-Deshattiwar/pg-DAC_COP_JAVA_Assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pg-DAC_COP_JAVA_Assignment

All java basic assignment of concept of programming(COP) module


******* Java Assignment Section-1 *********

  1. Get yourself acquainted with java environment. Find out "javac" & "java" in your JDK box.

  2. Understand the system variable : PATH

  3. Write a Java program to print 'Hello' on screen and then print your name on a separate line.

  4. Write a Java program to print 'Hello' on screen and then print your name on the same line.

  5. Write a program to take "name" as command line argument and print "Hello "+ on the console?

java MyFirstJavaProgram Shakir Hello Shakir

  1. Write a java program to take three numbers from command line and print the average ?

java Avg 5 6 4 Average=5

  1. Write a java program to calculate simple interest, get the required inputs from command line ? Hint : SimpleInterest = (principal * rate * years)/100.0

  2. Write a java program to convert temperature from celsius to fahrenheit, get input from command line ? Hint : F = (9*C/5) + 32

  3. Write a java program to print following face(pattern) on screen -

+"""""+
[| o o |]
| ^ |
| '-' |
+-----+

  1. Write a Java program to print the sum (addition), multiply, subtract, divide and remainder of two numbers received from command line?

// double x = Double.parseDouble(args[0]);


******* Java Assignment Section-2 ********* Prev=+8

  1. Write a program to take "name" from user using Scanner and greet as shown below-

Enter your name : Shakir Hello Shakir , Welcome to Java World.

  1. Write a java program to take 5 numbers using Scanner and print the average ?

Enter 5 numbers : 1 2 3 4 5 Average = 3

Enter 5 numbers : 2 3 5 7 9 Average = 5.2

  1. Write a java program to calculate simple interest, get the required inputs from Scanner ? Hint : SI = (principal * rate * years)/100

  2. Write a program to calculate the monthly in hand salary of an employee : take input for basic salary, HRA is 40% of basic salary, PF amount to be deducted is 12% of basic, Medical allowance is Rs 1200 per month, Traveling allowance is Rs 800 per month, Professional tax to be deducted is Rs 300.

  3. Write a Java program to print the area and perimeter of a rectangle. Take required input using Scanner?

Hint : Area = width * height Perimeter = 2 * ( width + height)

  1. Write a Java program to print the area and perimeter of a circle. Take required input using Scanner?

Hint : Area = Math.PI * radius * radius Perimeter = 2* Math.PI* radius

  1. Write a java program to calculate compound interest, get the required inputs using Scanner ?

  2. Write a java program to read roll no, name and marks of three subjects and calculate the total and percentage.

Test Data : Input the Roll Number of the student :784 Input the Name of the Student :James Input the marks of Physics, Chemistry and Computer Application : 70 80 90

Expected Output : Roll No : 784 Name of Student : James Marks in Physics : 70 Marks in Chemistry : 80 Marks in Computer Application : 90 Total Marks = 240 Percentage = 80.00


******* Java Assignment Section-3 ********* Prev=+16

  1. Write a java program to swap two numbers stored in local variables?

  2. Write a java program to swap two numbers stored in local variables without using additional variable?

  3. Write a java program to accept two integers and check whether they are equal or not?

Enter two integers : 15 15 first and second number are equal.

  1. Write a java program to check whether a given number is positive or negative?

  2. Write a java program to check whether a given number is even or odd?

  3. Write a java program to read age of a person, check if he/she is eligible to cast vote or not?

  4. Write a java program to read a number entered by user. Print -1 if this number is negative, 1 if it is positive, 0 if it is neither positive nor negative?

  5. Write a program to find the largest of two numbers?

  6. Write a program to find the largest of three numbers?

  7. Write a program to find the smallest of five numbers?

  8. Write a java program to read roll no, name and marks of three subjects and calculate the total, percentage and division.

Test Data : Input the Roll Number of the student :784 Input the Name of the Student :James Input the marks of Physics, Chemistry and Computer Application : 70 80 90

Expected Output : Roll No : 784 Name of Student : James Marks in Physics : 70 Marks in Chemistry : 80 Marks in Computer Application : 90 Total Marks = 240 Percentage = 80.00 Division = First

  1. Write a java program to read temperature in centigrade and display a suitable message according to temperature state below : Temp < 0 then Freezing weather Temp 0-10 then Very Cold weather Temp 10-20 then Cold weather Temp 20-30 then Normal in Temp Temp 30-40 then Its Hot Temp >=40 then Its Very Hot

Test Data : 42 Expected Output : Its very hot.

  1. Write a Java program to print the ascii value of a given character?

  2. Write a Java program that takes a year from user and print whether that year is a leap year or not.

Hint : a leap year is divisible by 4 and (not div by 100 or if div by both 100 &400)

  1. Write a java program to check if a given number is divisble by 3 and 5 ?

  2. Write a java program to ask user to enter test marks of three subjects such as Phy, Chem, Math. Max marks for each subject is 100. Now calculate average of marks. Display following message based on average marks calculated -

avg < 30 : You are failed. avg >= 30 but < 60 : You passed with Second division avg >=60 but < 80 : You passed wirh Fiear division avg>=80 : You passed with First class distinction

  1. Write a java program to ask user to enter a number between 1 and 7, print week day as per below mappings - (1 - Monday, 2-Tuesday, .... 7-Sunday)

  2. Write a Java program to check if character entered by user is a vowel, consonant or other character?

  3. Write a java program to ask user to enter month number (1-12) , print month name as per below mappings - (1 - January, 2-Feburary ... 12- December)

  4. Write a program to read 5 numbers from user, print the second highest number?


******* Java Assignment Section-4 ********* +36

  1. Write a java program to print first 10 natural numbers and their sum?

  2. Write a java program to read 10 numbers from keyboard and find their sum and average?

  3. Write a program in java to display the multiplication table of a given integer?

Enter the number : 5 5 X 1 = 5 5 X 2 = 10 . . 5 X 10 = 50

  1. Write a program to calculate the factorial of the given number?

  2. Write a program to display the pattern like right angle triangle using an asterisk as shown below:

**



  1. Write a program to display the pattern like right angle triangle with a number as shown below : 1 12 123 1234

  2. Write a program to make such a pattern like right angle triangle with a number which will repeat a number in a row, as shown below : 1 22 333 4444

  3. Write a program to make such a pattern like right angle triangle with number increased by 1 as shown below : 1 2 3 4 5 6 7 8 9 10

  4. Write a program to make such a pattern like a pyramid with an asterisk, as show below : *



  1. Write a program to make such a pattern like a pyramid with a number which will repeat the number in the same row as shown below : 1 2 2 3 3 3 4 4 4 4

  2. Write a program to check whether a given number is a perfect number or not?

Note : Defintion of Perfect Number : sum of all divisor of the number is equal to the number itself. eg. Number = 6 is perfrect because All positive divisor = 1 2 3, their sum=6

  1. Write a program to check whether a given number is an armstrong number or not?

Note : When the sum of the cube of the individual digits of a number is equal to that number, the number is called Armstrong number. For Example 153 is an Armstrong number because 153 = 1^3 +5^3 + 3^3.

  1. Write a program to determine whether a given number is prime or not?

  2. Write a program to display the first n terms of Fibonacci series.

Fibonacci series 0 1 2 3 5 8 13 ..... Test Data : Input number of terms to display : 10 Expected Output : Here is the Fibonacci series upto to 10 terms : 0 1 1 2 3 5 8 13 21 34

  1. Write a program to display the number in reverse order.

  2. Write a program to check whether a number is a palindrome or not. Note: If reverse of a number is same as that of number , then it is called palindrome. eg. 11, 151, 121,

  3. Write a program to check whether a given number is a Strong Number or not? Note : If sum of factorial of each digit of a number is equal to that number, then that number is called strong number.

  4. Write a program to find the length of a string without using the library function?

  5. Write a program to print all numbers between 1 & 100 which are divisible by 3 and 5 both?


******* Java Assignment Section-5 ********* Prev = 36+19=55

  1. Create a class Emp with fields like empId, name,dept,salary,address. Write required constructors for initialization Write a method displayEmpDetails() in the same class.

Write another test class , where you have to take emp details from user using Scanner and create object and call methods.

  1. Create a class Circle, it will have only one constructor which accepts radius as an argument. Write two methods in the class - calcuateArea(), calculatePermiter(). Write test class to test method calls.

class Circle{ int rad; Circle(int r){this.rad = r;} double calArea(){} double calPerimeter(){} }

******* Java Assignment Section-6 ********* Prev=57

  1. Install Eclipse with help of lab faculty, write and run some java programs. Set it up for java 8.

  2. Practice whatever is tought in the classroom - final, access modifier, constructors

  3. Write a menu driven billing system for a Snacks center, items available are Tea(Rs. 10), Samosa (Rs. 20), Sandwitch(Rs. 50), Green Tea (Rs. 15) etc. as follows -

****Welcome to Snack Center *********

  1. Tea (Rs. 10)

  2. Green Tea (Rs. 15)

  3. Samosa (Rs. 20)

  4. Sandwitch (Rs. 50)

  5. Generate Bill & Exit Enter your choice : 1 Enter quantity : 2

  6. Tea (Rs. 10)

  7. Green Tea (Rs. 15)

  8. Samosa (Rs. 20)

  9. Sandwitch (Rs. 50)

  10. Generate Bill & Exit Enter your choice : 3 Enter quantity : 3

  11. Tea (Rs. 10)

  12. Green Tea (Rs. 15)

  13. Samosa (Rs. 20)

  14. Sandwitch (Rs. 50)

  15. Generate Bill & Exit Enter your choice : 5

*BILL Tea 2 20 Samosa 3 6

Total = 80


******* Java Assignment Section-7 ********* Prev 58

  1. Write a java class named as NumUtil with following static methods to - double getPower(double x, int n) long getFactorial(int num); boolean isPrime(int num); boolean isEven(int num); boolean isOdd(int num);

1.1) Write test class named as NumUtilMain to test all these methods.

1.2) Extends question 2.1 to make it menu driven, based on the user choice , read relevant data from user and call static methods.


******* Java Assignment Section-8 ********* Prev 59

  1. Write a program to calculate average of numbers stored in an array?

  2. Write a program to reverse an array of elements?

  3. Write a program to find out highest and second highest number in an array?

  4. Write a Java program to copy an array to another by iterating the array?

  5. Write a program to concatenate two arrays (merge two array to new one)? a[] = {1,2,3} b[] = {4,5} c[] = {1,2,3,4,5}

  6. Write a Java program to test if an array contains a specific value?

  7. Write a Java program to find the index of an array element?

  8. Write a Java program to find the duplicate values of an array of integer values?

  9. Write a Java program to find the common elements between two arrays of integers?

  10. Write a program to add two matrix of numbers?

  11. Write a program to Sort an array in ascending order? [Notes : Arrays.sort()]

  12. Write a program to Sort strings in alphabetical order?


******* Java Assignment Section-9 ********* Prev 59+12=71

  1. Write a java program to print first 10 natural number using recursion?

  2. Write a java program to calculate the sum of numbers from 1 to N using recursion?

  3. Write a program to calculate the product of two integers using recursion? (Multiplication & Division operators are not allowed)

  4. Write a program to calculate the power of any number using recursion?

  5. Write a recursive program to print Fibonacci Series for given number of terms?

Input number of terms for the Series (< 20) : 10
The Series are :
1 1 2 3 5 8 13 21 34 55

  1. Write a program to find the sum of digits of a number using recursion?

  2. Write a program to find the Factorial of a number using recursion?

  3. Write a program to get the largest element of an array using recursion?

Total : 71+8 = 79

About

All java basic assignment of concept of programming(COP) module

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages