Java

Practice Assignments

  1. Simple Calculator
  2. Take Num1 as first number, Num2 as second number, calculate and print the following
    Sum=num1+num2
    Diff=num1-num2
    Prod=num1*num2
    Div1= Decimal value of num1/num2
    Div2= Quotient of num1/num2
    Rem1= Reminder of num1/num2
    Exp1=num1 to the power of num2

  3. Simple Calculator by taking Input Num1 and Num2 from a Text File
  4. Create a text file in1.txt with 2 numbers written one below the other. Line 1 should contain 8, Line 2 should contain 4
    Print Sum, Diff, Prod, Div1, Div2, Rem1, Exp1 on a single value separated by a space
    Create a text file file in2.txt with 2 numbers written on a single line separated by a comma. Eg 8,4
    Print Sum, Diff, Prod, Div1, Div2, Rem1, Exp1 on a single value separated by a space
    Create a text file out1.txt which will print the above results on a single line separated by a space
    Create a text file out2.txt which will print the avove results on different lines
    Create a text file out2.txt which will print the avove results on different lines along with the labels on the left side. Eg Sum of 8 and 4 is:

  5. Even, Odd and Prime Numbers
  6. Take Start and End as two inputs and print all Even Numbers between them separated by a space
    Take Start and End as two inputs and bring all Odd Numbers between them separated by a space
    Take Start and End as two inputs and create two ArrayLists even[] and odd[] containing Even and Odd Numbers respectively
    Create a list called list3[] containing multiples of 3 from 1 to 100. Eg 3, 6, 9, 12
    Create a list called list4[] containing mulitples of 4 from 1 to 100. Eg 4, 8, 12, 16
    Create a list called list5[], list6[], list7[], list8[] and list9[]
    Create a list called prime[] containing only prime numbers

  7. Check if a Number if Positive, Negative or Zero
  8. Take Num1 as input and determine if it is Postive, Negative or Zero
    Take in3.txt as input containing 10 numbers 4, -8, 0, 2, 9, -3, 7.5, 6, 0, 999. Create 3 different files positive.txt, negative.txt, zero.txt containing positive, negative and zero numbers respectively

  9. Number Handling Assignment
  10. Swap the values of two variables without using a temporary variable.
    Calculate the factorial of a number entered by the user.
    Calculate the factorial of a number using recursion.
    Check if a number entered by the user is prime or not.
    Find the maximum of three numbers entered by the user.
    Print the Fibonacci series up to a given number.
    Calculate the sum of digits in a given number.

  11. String Handling and Conversion Assignment
  12. Check if a string entered by the user is a palindrome.
    Check if a given string is an anagram or not.
    Count the number of vowels in a string entered by the user.
    Reverse a string entered by the user.
    Find the area of a circle given its radius.
    Convert temperature from Celsius to Fahrenheit.

  13. Array Handling Assignment
  14. Find the largest element in an array. int[]even={2,4,6,8,10,20,40,80}
    Sort an array of integers in descending order. int[]even={10,20,40,80,160,320}
    find the common elements which are found in both the arrays.

  15. OOPs Rectangle and Circle
  16. Create a class called Rectangle with attributes length and width. Write methods to calculate the area and perimeter of the rectangle.
    Create a class called Circle with attributes radius and a method to calculate the area of the circle.

  17. OOPS Student
  18. Create a class called Student with attributes name and age. Implement getter and setter methods for these attributes.

  19. OOPS Bank Account
  20. Create a class called BankAccount with attributes accountNumber and balance. Write methods to deposit and withdraw money from the account.

  21. OOPS Car
  22. Create a class called Car with attributes make, model, and year. Implement a method to display the car details.

  23. OOPS Employee
  24. Create a class called Employee with attributes name, salary, and designation. Implement a method to calculate the yearly bonus based on the salary.

  25. OOPS Person
  26. Create a class called Person with attributes name and address. Implement a method to display the person's details.

  27. OOPS Book
  28. Create a class called Book with attributes title, author, and price. Implement a method to calculate the discounted price of the book.

  29. OOPS Shape1
  30. Create a class called Shape with an abstract method calculateArea(). Implement this class in subclasses such as Rectangle, Circle, and Triangle.

  31. OOPS Animal
  32. Create a class called Animal with methods eat() and sleep(). Implement subclasses such as Dog, Cat, and Bird with their own implementations of these methods.

  33. OOPS Bank2
  34. Create a class called Bank with methods to add and retrieve customer information. Implement a separate class called Customer to represent a bank customer.

  35. OOPS EmployeeManagement
  36. Create a class called EmployeeManagement with methods to add, update, and delete employee records. Implement a separate class called Employee to represent an employee.

  37. OOPS Shape2
  38. Create a class called Shape with a method draw() and implement subclasses such as Circle, Rectangle, and Triangle with their own implementations of the draw() method.

  39. OOPS Vehicle
  40. Create a class called Vehicle with methods start() and stop(). Implement subclasses such as Car, Motorcycle, and Truck with their own implementations of these methods.

  41. OOPS Bank Account 2
  42. Create a class called BankAccount with methods deposit() and withdraw(). Implement subclasses such as SavingsAccount and CheckingAccount with their own implementations of these methods.

  43. OOPS Person2
  44. Create a class called Person with attributes name and age. Implement an interface called Playable with a method play(). Implement subclasses such as Child and Adult that implement the Playable interface.

  45. OOPS Shape3
  46. Create a class called Shape with abstract methods calculateArea() and calculatePerimeter(). Implement subclasses such as Rectangle, Circle, and Triangle with their own implementations of these methods.

  47. OOPS Employee2
  48. Create a class called Employee with attributes name and salary. Implement an interface called Taxable with a method calculateTax(). Implement subclasses such as Manager and Engineer that implement the Taxable interface.

  49. OOPS Bank3
  50. Create a class called Bank with methods to perform banking operations such as openAccount(), closeAccount(), and transferFunds(). Implement a separate class called Account to represent a bank account.

  51. OOPS Shape3
  52. Create a class called Shape with attributes color and filled. Implement subclasses such as Circle, Rectangle, and Triangle that inherit from the Shape class and

  53. Java Assignment 12
  54. Java Assignment 12
  55. Java Assignment 12
  56. Java Assignment 12