├── Area_Of_Equilateral_Triangle.java ├── Area_Of_Rhombus.java ├── Area_of_circle.java ├── Area_of_isosceles_tri.java ├── Area_of_parallelogram.java ├── Area_of_rectangle.java ├── Area_of_triangle.java ├── Armstrong_num.java ├── Car.java ├── Circle_Methods.java ├── Commission_calculator.java ├── Curved_Surface_Area_Of_Cylinder.java ├── Discount_Of_Product.java ├── Electricity_Bill.java ├── FIRST_leet_code.java ├── Factorial.java ├── Factorial_Method.java ├── Fibo.java ├── Greeting_msg.java ├── Lalit.java ├── Largest_num.java ├── Marks_Method.java ├── Min_Max_Methods.java ├── Odd_Even_merhod.java ├── Odd_even_check.java ├── Palindrome_ornot.java ├── Perimeter_Of_Circle.java ├── Perimeter_Of_Equilateral_Triangle.java ├── Perimeter_Of_Parallelogram.java ├── Perimeter_Of_Rectangle.java ├── Perimeter_Of_Rhombus.java ├── Perimeter_Of_Square.java ├── Person.java ├── Prime_Check_Method.java ├── PrintLargestNumber.java ├── Print_all_factors.java ├── Product_Method.java ├── README.md ├── Simple_Intrest.java ├── Small_calculator.java ├── Str_Pool.java ├── SumAllinput.java ├── Sum_Method.java ├── Sum_of_N_naturam_num.java ├── Total_Surface_Area_Of_Cube.java ├── UNI ├── .vscode │ ├── LinearQueue.java │ ├── Notation_Conversion.java │ ├── Queue.java │ └── settings.json ├── AD_arr_print.java ├── Abstract_Shape.java ├── Abstract_final.java ├── Alphabets.java ├── Armstrong1000.java ├── Array_print_find_big_small.java ├── Binary_to_decimal.java ├── Book.java ├── CLI_output.java ├── Calculator.java ├── CheckEquality.java ├── Copy_array.java ├── Cricket.java ├── Even_print.java ├── Even_sum.java ├── Exception_handling.java ├── Fact.java ├── Fibonacci.java ├── Final_var_used.java ├── Football.java ├── Greeting_Msg.java ├── Hello_World.java ├── Hw.java ├── Increasing_order.java ├── Largest_element.java ├── LibraryFineCalculator.java ├── Login_System.java ├── MaxOfThree.java ├── Movie_Theatre.java ├── Multiple_of_5.java ├── NIntegers_sum.java ├── NaturalNumSum.java ├── NaturalNumbers.java ├── Number_of_digit.java ├── Odd_even_check.java ├── Odd_print.java ├── Odd_sum.java ├── Override.java ├── Pat_Print.java ├── Power.java ├── Previous_year_paper_question.java ├── Prime_Check.java ├── Rectangle.java ├── ReverseNaturalNumbers.java ├── ReverseNumberCheck.java ├── Reverse_Digit.java ├── Star_Pattern.java ├── Static_keyword.java ├── Switch_Case_Week.java ├── Switch_Case_Weekday.java ├── Table.java ├── Two_metrics_areequal.java └── WorkerEfficiency.java ├── Usd_to_inr.java ├── Volume_Of_Cone.java ├── Volume_Of_Cylinder.java ├── Volume_Of_Prism.java ├── Volume_Of_Pyramid.java ├── Volume_Of_Sphere.java ├── Vote_method.java └── Vowel_check.java /Area_Of_Equilateral_Triangle.java: -------------------------------------------------------------------------------- 1 | 2 | //7. Area Of Equilateral Triangle 3 | import java.util.Scanner; 4 | public class Area_Of_Equilateral_Triangle{ 5 | public static void main(String[] args) { 6 | Scanner in = new Scanner(System.in); 7 | double root = 0.4330127019; 8 | System.out.print("Enter side:"); 9 | double side = in.nextDouble(); 10 | System.out.println(root*(side*side)); 11 | in.close(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Area_Of_Rhombus.java: -------------------------------------------------------------------------------- 1 | //6. Area Of Rhombus 2 | import java.util.Scanner; 3 | public class Area_Of_Rhombus{ 4 | public static void main(String[] args) { 5 | Scanner in = new Scanner(System.in); 6 | System.out.print("Enter Base:"); 7 | int base = in.nextInt(); 8 | System.out.print("Enter Height:"); 9 | int height = in.nextInt(); 10 | System.out.println(base*height); 11 | in.close(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Area_of_circle.java: -------------------------------------------------------------------------------- 1 | //1. Area Of Circle Java Program 2 | 3 | import java.util.Scanner; 4 | public class Area_of_circle { 5 | public static void main(String[] args) { 6 | Scanner in = new Scanner(System.in); 7 | double pie = 3.14159; 8 | System.out.print("Enter the radius:"); 9 | double radius = in.nextDouble(); 10 | double area = pie*(radius*radius); 11 | System.out.println(area); 12 | in.close(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Area_of_isosceles_tri.java: -------------------------------------------------------------------------------- 1 | //4. Area Of Isosceles Triangle 2 | import java.util.Scanner; 3 | public class Area_of_isosceles_tri { 4 | public static void main(String[] args) { 5 | Scanner in = new Scanner(System.in); 6 | System.out.print("Enter Base:"); 7 | int B = in.nextInt(); 8 | System.out.print("Enter Height:"); 9 | int H = in.nextInt(); 10 | System.out.println((B*H)/2); 11 | in.close(); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Area_of_parallelogram.java: -------------------------------------------------------------------------------- 1 | //5. Area Of Parallelogram 2 | import java.util.Scanner; 3 | public class Area_of_parallelogram { 4 | public static void main(String[] args) { 5 | Scanner in = new Scanner(System.in); 6 | System.out.print("Enter base:"); 7 | int B = in.nextInt(); 8 | System.out.print("Enter height:"); 9 | int H = in.nextInt(); 10 | System.out.println(B*H); 11 | in.close(); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Area_of_rectangle.java: -------------------------------------------------------------------------------- 1 | //3. Area Of Rectangle Program 2 | import java.util.Scanner; 3 | public class Area_of_rectangle { 4 | public static void main(String[] args) { 5 | Scanner in = new Scanner(System.in); 6 | System.out.print("Enter width:"); 7 | int width = in.nextInt(); 8 | System.out.print("Enter length:"); 9 | int length = in.nextInt(); 10 | System.out.println(width*length); 11 | in.close(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Area_of_triangle.java: -------------------------------------------------------------------------------- 1 | //2. Area Of Triangle 2 | 3 | import java.util.Scanner; 4 | public class Area_of_triangle { 5 | public static void main(String[] args) { 6 | Scanner in = new Scanner(System.in); 7 | System.out.print("Enter base:"); 8 | int B = in.nextInt(); 9 | System.out.print("Enter height:"); 10 | int H = in.nextInt(); 11 | System.out.println((B*H)/2); 12 | in.close(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Armstrong_num.java: -------------------------------------------------------------------------------- 1 | //9. To find Armstrong Number between two given number. 2 | import java.util.Scanner; 3 | public class Armstrong_num { 4 | public static void main(String args[]){ 5 | int num1, num2; 6 | Scanner in = new Scanner(System.in); 7 | System.out.print("Enter the first number:"); 8 | num1 = in.nextInt(); 9 | System.out.print("Enter the second number:"); 10 | num2 = in.nextInt(); 11 | in.close(); 12 | for (int i = num1; i0) 10 | { 11 | int r=n%10; 12 | P=P*r; 13 | sum=sum+r; 14 | n=n/10; 15 | } 16 | System.out.println(P-sum); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Factorial.java: -------------------------------------------------------------------------------- 1 | //1. Factorial Program In Java 2 | import java.util.Scanner; 3 | public class Factorial { 4 | public static void main(String[] args) { 5 | Scanner in = new Scanner(System.in); 6 | int i,fact=1; 7 | int number= in.nextInt(); 8 | in.close(); 9 | for(i=1;i<=number;i++){ 10 | fact=fact*i; 11 | } 12 | System.out.println("Factorial of "+number+" is: "+fact); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Factorial_Method.java: -------------------------------------------------------------------------------- 1 | /*9. [Write a program to print the factorial of a number by defining a method named 'Factorial'.] 2 | (https://www.javatpoint.com/factorial-program-in-java) 3 | Factorial of any number n is represented by n! and is equal to 1 * 2 * 3 * .... * (n-1) *n. E.g. 4 |
 5 | 4! = 1 * 2 * 3 * 4 = 24 
 6 | 3! = 3 * 2 * 1 = 6 
 7 | 2! = 2 * 1 = 2 
 8 | Also, 
 9 | 1! = 1 
10 | 0! = 1*/
11 | 
12 | import java.util.Scanner;
13 | public class Factorial_Method{
14 |     public static void main(String[] args) {
15 |     Scanner in = new Scanner (System.in);
16 |     System.out.print("Enter the number:");
17 |     int num = in.nextInt();
18 |     in.close();
19 |     Fact(num);
20 |     }
21 |     static void Fact(int num){
22 |         int fact = 1;
23 |         for(int i=1;i<=num;i++){    
24 |             fact=fact*i;
25 |             System.out.println(num  +  " = " + i + " * " + fact );
26 |     }
27 | }
28 | }


--------------------------------------------------------------------------------
/Fibo.java:
--------------------------------------------------------------------------------
 1 | //7. To calculate Fibonacci Series up to n numbers.
 2 | import java.util.Scanner;
 3 | public class Fibo {
 4 |     public static void main(String[] args) {
 5 |          Scanner in = new Scanner(System.in);
 6 |             int n = in.nextInt();
 7 |             int p = 0;
 8 |             int i = 1;
 9 |             int count = 2;
10 | 
11 |             while (count <= n) {
12 |                 int temp = i;
13 |                 i = i + p;
14 |                 p = temp;
15 |                 count++;  
16 |             }
17 |             System.out.println(i);
18 |             // int acb = 234_000_000;
19 |             // System.out.println(acb);
20 |             
21 |             //int a ='@';
22 |             //System.out.print(a);
23 |             in.close();
24 |     }
25 |     
26 | }
27 | 


--------------------------------------------------------------------------------
/Greeting_msg.java:
--------------------------------------------------------------------------------
 1 | //2. Take name as input and print a greeting message for that particular name.
 2 | 
 3 | import java.util.Scanner;
 4 | 
 5 | public class Greeting_msg {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in); 
 8 | 
 9 |         System.out.print("What is your name:");
10 | 
11 |         String name = in.nextLine();
12 |         
13 |         System.out.println("HELLO! " + name + " How are you?" );
14 |         in.close();
15 |     }
16 |     
17 | }
18 | 


--------------------------------------------------------------------------------
/Lalit.java:
--------------------------------------------------------------------------------
 1 | 
 2 | public class Lalit {
 3 | 
 4 |     public static void main(String[] args) {
 5 | 
 6 |         System.out.print("Hello World");
 7 | 
 8 |     }
 9 | }
10 | 


--------------------------------------------------------------------------------
/Largest_num.java:
--------------------------------------------------------------------------------
 1 | //5. Take 2 numbers as input and print the largest number.
 2 | 
 3 | import java.util.Scanner;
 4 | 
 5 | public class Largest_num {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter first number:");
 9 |         int a = in.nextInt();
10 |         System.out.print("Enter second number:");
11 |         int b = in.nextInt();
12 |         if (a > b) {
13 |             System.out.println("Largest number is:" + a );
14 |         }
15 |         else {
16 |             System.out.println("Largest number is:" + b);
17 |             in.close();
18 |         }
19 |     }
20 | }
21 | 


--------------------------------------------------------------------------------
/Marks_Method.java:
--------------------------------------------------------------------------------
 1 | /*8. [Write a program that will ask the user to enter his/her marks (out of 100). 
 2 | Define a method that will display grades according to the marks entered as below:]
 3 | (https://www.techcrashcourse.com/2017/02/java-program-to-calculate-grade-of-students.html)
 4 | Marks        Grade 
 5 | 91-100         AA 
 6 | 81-90          AB 
 7 | 71-80          BB 
 8 | 61-70          BC 
 9 | 51-60          CD 
10 | 41-50          DD 
11 | <=40          Fail */
12 | import java.util.Scanner;
13 | public class Marks_Method {
14 |     public static void main(String[] args) {
15 |         Scanner in = new Scanner(System.in);
16 |         System.out.print("Enter your marks:");
17 |         float marks = in.nextFloat();
18 |         in.close();
19 |         Marks(marks);
20 |     }
21 |     static void Marks(float marks){
22 |         if (marks>100){
23 |             System.out.println("Please enter valid marks");
24 |         }
25 |         else if (marks>=91){
26 |             System.out.println("Your grade is AA");
27 |         }
28 |         else if (marks>=81){
29 |             System.out.println("Your grade is AB");
30 |         }
31 |         else if (marks>=71){
32 |             System.out.println("Your grade is BB");
33 |         }
34 |         else if (marks>=61){
35 |             System.out.println("Your grade is BC");
36 |         }
37 |         else if (marks>=51){
38 |             System.out.println("Your grade is CD");
39 |         }
40 |         else if (marks>=41){
41 |             System.out.println("Your grade is DD");
42 |         }
43 |         else {
44 |             System.out.println("FAIL!!!!!!!!!!!!!!!!!");
45 |         }
46 |     }
47 |     
48 | }
49 | 


--------------------------------------------------------------------------------
/Min_Max_Methods.java:
--------------------------------------------------------------------------------
 1 | /*1. [Define two methods to print the maximum and the minimum number respectively among three numbers entered by the user.]
 2 | (https://www.java67.com/2019/05/how-to-find-largest-and-smallest-of-three-numbers-in-java.html)*/
 3 | import java.util.Scanner;
 4 | public class Min_Max_Methods {
 5 |     public static void main(String[] args) {
 6 |         Scanner in = new Scanner(System.in);
 7 |         System.out.print("Enter the first number:");
 8 |         int a = in.nextInt();
 9 |         System.out.print("Enter the second number:");
10 |         int b = in.nextInt();
11 |         System.out.print("Enter the third number:");
12 |         int c = in.nextInt();
13 |         in.close();
14 |         int max = min(a, b, c);
15 |         int min = max(a, b, c);
16 |         System.out.println("The maximum number is: " + max);
17 |         System.out.print("The minimum number is: " + min);
18 | 
19 |     }
20 |     static int min (int a , int b , int c){
21 |         int minimum = 0;
22 |         if (ab & c>b){
26 |          minimum = b;
27 |         }
28 |         else{
29 |          minimum = c;
30 |         }
31 |         return minimum;
32 |     }
33 | 
34 |     static int max (int a , int b , int c){
35 |         int maximum = 0;
36 |         if (ab & a>c){
40 |          maximum = a;
41 |         }
42 |         else{
43 |          maximum = c;
44 |         }
45 |         return maximum;
46 |     }
47 | 
48 | 
49 | }


--------------------------------------------------------------------------------
/Odd_Even_merhod.java:
--------------------------------------------------------------------------------
 1 | /*2. [Define a program to find out whether a given number is even or odd.]
 2 | (https://www.geeksforgeeks.org/java-program-to-check-if-a-given-integer-is-odd-or-even/)*/
 3 | import java.util.Scanner;
 4 | public class Odd_Even_merhod {
 5 |     public static void main(String[] args) {
 6 |         Scanner in = new Scanner(System.in);
 7 |         System.out.print("Enter the number:");
 8 |         int num = in.nextInt();
 9 |         in.close();
10 |         System.out.println(Odd_Even(num)); 
11 |     }
12 |     static String Odd_Even (int a ){
13 |          String ans;
14 |         if (a%2==0){
15 |             ans = "Even";
16 |         }
17 |         else {
18 |             ans = "Odd";
19 |         }
20 |         return ans;
21 |     }
22 | }
23 | 


--------------------------------------------------------------------------------
/Odd_even_check.java:
--------------------------------------------------------------------------------
 1 | /*1. Write a program to print whether a number is even or odd, also take
 2 | input from the user.*/
 3 | import java.util.Scanner;
 4 | public class Odd_even_check {
 5 |     public static void main(String[] args) {
 6 |         Scanner in = new Scanner(System.in);
 7 |         int num = in.nextInt();
 8 |         if (num % 2 == 0) {
 9 |             System.out.println("The Number is Even");
10 |         }
11 |         else{
12 |             System.out.println("The Number is Odd");
13 |             in.close();
14 |         } 
15 |     }
16 |     
17 | }
18 | 


--------------------------------------------------------------------------------
/Palindrome_ornot.java:
--------------------------------------------------------------------------------
 1 | //8. To find out whether the given String is Palindrome or not.
 2 | 
 3 | public class Palindrome_ornot {
 4 |     
 5 |             public static void main(String[] args) {
 6 |           
 7 |               String str = "Radar", reverseStr = "";
 8 |               
 9 |               int strLength = str.length();
10 |           
11 |               for (int i = (strLength - 1); i >=0; --i) {
12 |                 reverseStr = reverseStr + str.charAt(i);
13 |               }
14 |           
15 |               if (str.toLowerCase().equals(reverseStr.toLowerCase())) {
16 |                 System.out.println(str + " is a Palindrome String.");
17 |               }
18 |               else {
19 |                 System.out.println(str + " is not a Palindrome String.");
20 |                 
21 |               }
22 |             }
23 | }
24 |     
25 |     
26 | 
27 | 


--------------------------------------------------------------------------------
/Perimeter_Of_Circle.java:
--------------------------------------------------------------------------------
 1 | //8. Perimeter Of Circle
 2 | import java.util.Scanner;
 3 | public class Perimeter_Of_Circle {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter radius:");
 7 |         double R = in.nextFloat();
 8 |         double P = 2*3.14*R;
 9 |         System.out.println(P);
10 |         in.close();
11 |     }
12 |     
13 | }
14 | 


--------------------------------------------------------------------------------
/Perimeter_Of_Equilateral_Triangle.java:
--------------------------------------------------------------------------------
 1 | //9. Perimeter Of Equilateral Triangle
 2 | import java.util.Scanner;
 3 | public class Perimeter_Of_Equilateral_Triangle {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter the side:");
 7 |         double S = in.nextDouble();
 8 |         System.out.println(3*S);
 9 |         in.close();
10 |         }
11 |     }
12 | 


--------------------------------------------------------------------------------
/Perimeter_Of_Parallelogram.java:
--------------------------------------------------------------------------------
 1 | //10. Perimeter Of Parallelogram
 2 | import java.util.Scanner;
 3 | public class Perimeter_Of_Parallelogram{
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter Base:");
 7 |         double B =in.nextDouble();
 8 |         System.out.print("Enter side:");
 9 |         double S =in.nextDouble();
10 |         System.out.println(2*(B+S));
11 |         in.close();
12 |     }
13 | }


--------------------------------------------------------------------------------
/Perimeter_Of_Rectangle.java:
--------------------------------------------------------------------------------
 1 | //11. Perimeter Of Rectangle
 2 | import java.util.Scanner;
 3 | public class Perimeter_Of_Rectangle {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter length:");
 7 |         double L = in.nextDouble();
 8 |         System.out.print("Enter width:");
 9 |         double W = in.nextDouble();
10 |         System.out.println(2*(L+W));
11 |         in.close();
12 |     }
13 |     
14 | }
15 | 


--------------------------------------------------------------------------------
/Perimeter_Of_Rhombus.java:
--------------------------------------------------------------------------------
 1 | //12. Perimeter Of Rhombus
 2 | import java.util.Scanner;
 3 | public class Perimeter_Of_Rhombus {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter the side:");
 7 |         double S = in.nextDouble();
 8 |         System.out.println(4*S);
 9 |         in.close();
10 |         }
11 | }


--------------------------------------------------------------------------------
/Perimeter_Of_Square.java:
--------------------------------------------------------------------------------
 1 | //12. Perimeter Of Square
 2 | import java.util.Scanner;
 3 | public class Perimeter_Of_Square {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter the side:");
 7 |         double S = in.nextDouble();
 8 |         System.out.println(4*S);
 9 |         in.close();
10 |         }
11 | }
12 | 


--------------------------------------------------------------------------------
/Person.java:
--------------------------------------------------------------------------------
 1 | public class Person {
 2 |     String name;
 3 |     String address;
 4 |     int age;
 5 | 
 6 |     Person() {
 7 |         name = "no name";
 8 |         address = "no address";
 9 |         age = 0;
10 |     }
11 | 
12 |     Person(String name1, String addres1, int age1) {
13 |         name = name1;
14 |         address = addres1;
15 |         age = age1;
16 |     }
17 | 
18 |     public static void main(String[] args) {
19 |         Person person = new Person();
20 |         Person person2 = new Person("Bharat", "agra", 20);
21 |         System.out.println(person.name);
22 |         System.out.println(person.address);
23 |         System.out.println(person.age);
24 |         System.out.println(person2.name);
25 |         System.out.println(person2.address);
26 |         System.out.println(person2.age);
27 | 
28 |     }
29 | 
30 | }


--------------------------------------------------------------------------------
/Prime_Check_Method.java:
--------------------------------------------------------------------------------
 1 | /*7. [Define a method to find out if a number is prime or not.]
 2 | (https://www.geeksforgeeks.org/java-program-to-check-if-a-number-is-prime-or-not/)*/
 3 | import java.util.Scanner;
 4 | public class Prime_Check_Method {
 5 |     public static void main(String[] args) {
 6 |         Scanner in = new Scanner(System.in);
 7 |         System.out.print("Enter the number:");
 8 |         int num = in.nextInt();
 9 |         in.close();
10 |         Prime_Check(num);
11 |     }
12 |      static void Prime_Check(int num) {
13 |         int count = 0;
14 |         if (num <= 1  || num <=0) {
15 |             System.out.println("The number is not prime");
16 |         }
17 |         else {
18 |             for(int i=2;i==num;i++){
19 |                 if (num%i==0){
20 |                     count = 1;
21 |                 }
22 |             }
23 |         }
24 |         if (count==1) {
25 |             System.out.println("The number is prime");
26 |         }
27 |         else 
28 |         {
29 |             System.out.println("The number is not prime");
30 |         }
31 |     }
32 | }
33 | 


--------------------------------------------------------------------------------
/PrintLargestNumber.java:
--------------------------------------------------------------------------------
 1 | /*25. Take integer inputs till the user enters 0 and print the largest number from
 2 | all.*/
 3 | import java.util.Scanner;
 4 | public class PrintLargestNumber {
 5 |     public static void main(String[] args) {
 6 |         long largest_num = 0;
 7 |         Scanner in = new Scanner(System.in);
 8 |         while (true) {
 9 |             System.out.print("Enter the number:");
10 |             long num = in.nextLong();
11 |             if (num > largest_num) {
12 |                 largest_num = num;
13 |             }
14 |             else if (num == 0 ){
15 |                 System.out.println("Largest number is :" + largest_num);
16 |                 break;
17 |             }
18 |             in.close();
19 |         }
20 |     }
21 | }
22 | 


--------------------------------------------------------------------------------
/Print_all_factors.java:
--------------------------------------------------------------------------------
 1 | //23. Input a number and print all the factors of that number (use loops).
 2 | import java.util.Scanner;
 3 | public class Print_all_factors {
 4 |      public static void main(String[] args) {
 5 |             Scanner in = new Scanner(System.in);
 6 |             System.out.print("Enter the number: ");
 7 |             long n = in.nextLong();
 8 |             in.close();
 9 |             
10 |             for (long i = 1; i <= n; i++) {
11 |                 if (n % i == 0) {
12 |                     System.out.println(i);
13 |                 
14 |             }
15 |         }
16 |     }
17 | }   
18 | 


--------------------------------------------------------------------------------
/Product_Method.java:
--------------------------------------------------------------------------------
 1 | /*5. [Define a method that returns the product of two numbers entered by user.]
 2 | (https://code4coding.com/java-program-to-multiply-two-numbers-using-method/)*/
 3 | import java.util.Scanner;
 4 | public class Product_Method{
 5 |     public static void main(String[] args) {
 6 |         Scanner in = new Scanner(System.in);
 7 |         System.out.print("Enter the first number:");
 8 |         int a = in.nextInt();
 9 |         System.out.print("Enter the second number:");
10 |         int b = in.nextInt();
11 |         in.close();
12 |         System.out.println(Product(a , b ));  
13 |     }
14 |     static int Product(int a , int b){
15 |        int prod = a*b;
16 |        return prod;
17 |     }
18 | }


--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | 


--------------------------------------------------------------------------------
/Simple_Intrest.java:
--------------------------------------------------------------------------------
 1 | /*3. Write a program to input principal, time, and rate (P, T, R) from the user and
 2 | find Simple Interest. */
 3 | import java.util.Scanner;
 4 | public class Simple_Intrest {
 5 |     public static void main(String[] args) {
 6 |         Scanner in = new Scanner(System.in);
 7 |         System.out.print("Please enter the principal amount:");
 8 |         int amount = in.nextInt();
 9 |         System.out.println();
10 |         System.out.print("Please enter the time in years:");
11 |         int time = in.nextInt();
12 |         System.out.println();
13 |         System.out.print("Please enter the rate:");
14 |         int rate = in.nextInt();
15 |         System.out.println();
16 |         int si = (amount*rate*time)/100;
17 |         System.out.println("Your simple intrest is:"+si);
18 |         in.close();
19 | 
20 |         
21 |     }
22 | }
23 | 


--------------------------------------------------------------------------------
/Small_calculator.java:
--------------------------------------------------------------------------------
 1 | /*4. Take in two numbers and an operator (+, -, *, /, %) and calculate the value.
 2 | (Use if conditions) */
 3 | import java.util.Scanner;
 4 | 
 5 | public class Small_calculator {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter number 1:");
 9 |         int num1 = in.nextInt();
10 |         System.out.print("Enter number 2:");
11 |         int num2 = in.nextInt();
12 |         System.out.print("Enter the operator:");
13 |         String op = in.next();
14 |         String plus = "+";
15 |         String minus = "-"; 
16 |         String multiply = "*";
17 |         String divide = "/"; 
18 |         String remainder = "%";
19 |         if (op.equals(plus)) {
20 |             System.out.print(num1+num2);
21 |         }
22 |         else if (op.equals(minus)) {
23 |             System.out.println(num1-num2);
24 |         }
25 |         else if (op.equals(multiply)) {
26 |             System.out.println(num1*num2);
27 |         }
28 |         else if (op.equals(divide)) {
29 |             System.out.println(num1/num2);
30 |         }
31 |         else if (op.equals(remainder)) {
32 |             System.out.println(num1%num2);
33 |         }
34 |         else {
35 |             System.out.println("invalid operator");
36 |         }
37 |         in.close();
38 |         
39 |     }
40 |     
41 | }
42 | 


--------------------------------------------------------------------------------
/Str_Pool.java:
--------------------------------------------------------------------------------
1 | public class Str_Pool {
2 |     public static void main(String[] args) {
3 |         // String name = "lalit";
4 |         String name2 = new String("lalit");
5 |         System.out.println(name2);
6 |     }
7 | }


--------------------------------------------------------------------------------
/SumAllinput.java:
--------------------------------------------------------------------------------
 1 | //24. Take integer inputs till the user enters 0 and print the sum of all numbers
 2 | import java.util.Scanner;
 3 | public class SumAllinput {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         double sum = 0;
 7 |         while (true) {
 8 |             System.out.print("Enter the number:");
 9 |             double n = in.nextDouble();
10 |             sum = sum +n;
11 |             if (n == 0){
12 |                 break;
13 |             }
14 |         }
15 |         System.out.println(sum);
16 |         in.close();
17 |     }
18 | }


--------------------------------------------------------------------------------
/Sum_Method.java:
--------------------------------------------------------------------------------
 1 | //4. [Write a program to print the sum of two numbers entered by user by defining your own method.]
 2 | //(https://code4coding.com/addition-of-two-numbers-in-java-using-method/)
 3 | 
 4 | import java.util.Scanner;
 5 | public class Sum_Method {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter the first number:");
 9 |         int num1 = in.nextInt();
10 |         System.out.print("Enter the first number:");
11 |         int num2 = in.nextInt();
12 |         in.close();
13 |         System.out.println(sum(num1 , num2));
14 |     }
15 |     static int sum (int num1 , int num2 ){
16 |         int sum = num1+num2;
17 |         return sum;
18 |     }
19 | }
20 | 


--------------------------------------------------------------------------------
/Sum_of_N_naturam_num.java:
--------------------------------------------------------------------------------
 1 | //14. [Write a function that returns the sum of first n natural numbers.]
 2 | //(https://www.geeksforgeeks.org/program-find-sum-first-n-natural-numbers/)
 3 | 
 4 | import java.util.Scanner;
 5 | public class Sum_of_N_naturam_num {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter the number:");
 9 |         int num = in.nextInt();
10 |         in.close();
11 |         System.out.println(Sum(num));
12 |     }
13 |     static int Sum (int num){
14 |         int sum=0;
15 |         for(int i = 1 ; i <= num ; i++){
16 |             sum=sum+i;
17 |         }
18 |         return sum;
19 |     }
20 | }
21 | 


--------------------------------------------------------------------------------
/Total_Surface_Area_Of_Cube.java:
--------------------------------------------------------------------------------
 1 | //20. Total Surface Area Of Cube
 2 | import java.util.Scanner;
 3 | public class Total_Surface_Area_Of_Cube {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter side:");
 7 |         double S = in.nextDouble();
 8 |         System.out.println(6*(S*S));
 9 |         in.close();
10 |         
11 |     }
12 |     
13 | }
14 | 


--------------------------------------------------------------------------------
/UNI/.vscode/LinearQueue.java:
--------------------------------------------------------------------------------
 1 | public class LinearQueue {
 2 |     private int[] arr;
 3 |     private int front, rear, capacity;
 4 | 
 5 |     public LinearQueue(int capacity) {
 6 |         this.capacity = capacity;
 7 |         arr = new int[capacity];
 8 |         front = 0;
 9 |         rear = -1;
10 |     }
11 | 
12 |     public boolean isFull() {
13 |         return rear == capacity - 1;
14 |     }
15 | 
16 |     public boolean isEmpty() {
17 |         return front > rear;
18 |     }
19 | 
20 |     public void enqueue(int item) {
21 |         if (isFull()) {
22 |             System.out.println("Queue is full. Cannot enqueue " + item);
23 |             return;
24 |         }
25 |         arr[++rear] = item;
26 |         System.out.println(item + " enqueued to queue");
27 |     }
28 | 
29 |     public int dequeue() {
30 |         if (isEmpty()) {
31 |             System.out.println("Queue is empty. Cannot dequeue.");
32 |             return -1;
33 |         }
34 |         return arr[front++];
35 |     }
36 | 
37 |     public void display() {
38 |         if (isEmpty()) {
39 |             System.out.println("Queue is empty.");
40 |             return;
41 |         }
42 |         System.out.print("Queue: ");
43 |         for (int i = front; i <= rear; i++) {
44 |             System.out.print(arr[i] + " ");
45 |         }
46 |         System.out.println();
47 |     }
48 | 
49 |     public int peek() {
50 |         if (isEmpty()) {
51 |             System.out.println("Queue is empty. Nothing to peek.");
52 |             return -1;
53 |         }
54 |         return arr[front];
55 |     }
56 | 
57 |     public static void main(String[] args) {
58 |         LinearQueue queue = new LinearQueue(5);
59 |         queue.enqueue(10);
60 |         queue.enqueue(20);
61 |         queue.enqueue(30);
62 |         queue.enqueue(40);
63 |         queue.enqueue(50);
64 |         queue.enqueue(60);
65 | 
66 |         queue.display();
67 | 
68 |         System.out.println("Dequeued: " + queue.dequeue());
69 |         System.out.println("Front element: " + queue.peek());
70 | 
71 |         queue.display();
72 |     }
73 | }
74 | 


--------------------------------------------------------------------------------
/UNI/.vscode/Notation_Conversion.java:
--------------------------------------------------------------------------------
  1 | import java.util.*;
  2 | 
  3 | public class Notation_Conversion {
  4 | 
  5 |     static boolean isOperator(char c) {
  6 |         return (!(c >= 'a' && c <= 'z') &&
  7 |                 !(c >= '0' && c <= '9') &&
  8 |                 !(c >= 'A' && c <= 'Z'));
  9 |     }
 10 | 
 11 |     static int getPriority(char C) {
 12 |         if (C == '-' || C == '+')
 13 |             return 1;
 14 |         else if (C == '*' || C == '/')
 15 |             return 2;
 16 |         else if (C == '^')
 17 |             return 3;
 18 |         return 0;
 19 |     }
 20 | 
 21 |     static String infixToPrefix(String infix) {
 22 | 
 23 |         Stack operators = new Stack();
 24 | 
 25 |         Stack operands = new Stack();
 26 | 
 27 |         for (int i = 0; i < infix.length(); i++) {
 28 | 
 29 |             if (infix.charAt(i) == '(') {
 30 |                 operators.push(infix.charAt(i));
 31 |             }
 32 | 
 33 |             else if (infix.charAt(i) == ')') {
 34 |                 while (!operators.empty() &&
 35 |                         operators.peek() != '(') {
 36 | 
 37 |                     String op1 = operands.peek();
 38 |                     operands.pop();
 39 | 
 40 |                     String op2 = operands.peek();
 41 |                     operands.pop();
 42 | 
 43 |                     char op = operators.peek();
 44 |                     operators.pop();
 45 | 
 46 |                     String tmp = op + op2 + op1;
 47 |                     operands.push(tmp);
 48 |                 }
 49 | 
 50 |                 operators.pop();
 51 |             }
 52 | 
 53 |             else if (!isOperator(infix.charAt(i))) {
 54 |                 operands.push(infix.charAt(i) + "");
 55 |             }
 56 | 
 57 |             else {
 58 |                 while (!operators.empty() &&
 59 |                         getPriority(infix.charAt(i)) <= getPriority(operators.peek())) {
 60 | 
 61 |                     String op1 = operands.peek();
 62 |                     operands.pop();
 63 | 
 64 |                     String op2 = operands.peek();
 65 |                     operands.pop();
 66 | 
 67 |                     char op = operators.peek();
 68 |                     operators.pop();
 69 | 
 70 |                     String tmp = op + op2 + op1;
 71 |                     operands.push(tmp);
 72 |                 }
 73 | 
 74 |                 operators.push(infix.charAt(i));
 75 |             }
 76 |         }
 77 | 
 78 |         while (!operators.empty()) {
 79 |             String op1 = operands.peek();
 80 |             operands.pop();
 81 | 
 82 |             String op2 = operands.peek();
 83 |             operands.pop();
 84 | 
 85 |             char op = operators.peek();
 86 |             operators.pop();
 87 | 
 88 |             String tmp = op + op2 + op1;
 89 |             operands.push(tmp);
 90 |         }
 91 | 
 92 |         return operands.peek();
 93 |     }
 94 | 
 95 |     public static void main(String args[]) {
 96 |         String s = "(A-B/C)*(A/K-L)";
 97 |         System.out.println(infixToPrefix(s));
 98 |     }
 99 | }
100 | 


--------------------------------------------------------------------------------
/UNI/.vscode/Queue.java:
--------------------------------------------------------------------------------
 1 | public class Queue {
 2 |     private int[] arr;
 3 |     private int front, rear, size, capacity;
 4 | 
 5 |     public Queue(int capacity) {
 6 |         this.capacity = capacity;
 7 |         arr = new int[capacity];
 8 |         front = 0;
 9 |         rear = -1;
10 |         size = 0;
11 |     }
12 | 
13 |     public boolean isFull() {
14 |         return size == capacity;
15 |     }
16 | 
17 |     public boolean isEmpty() {
18 |         return size == 0;
19 |     }
20 | 
21 |     public void enqueue(int item) {
22 |         if (isFull()) {
23 |             System.out.println("Queue is full. Cannot enqueue " + item);
24 |             return;
25 |         }
26 |         rear = (rear + 1) % capacity;
27 |         arr[rear] = item;
28 |         size++;
29 |         System.out.println(item + " enqueued to queue");
30 |     }
31 | 
32 |     public int dequeue() {
33 |         if (isEmpty()) {
34 |             System.out.println("Queue is empty. Cannot dequeue.");
35 |             return -1;
36 |         }
37 |         int item = arr[front];
38 |         front = (front + 1) % capacity;
39 |         size--;
40 |         return item;
41 |     }
42 | 
43 |     public int peek() {
44 |         if (isEmpty()) {
45 |             System.out.println("Queue is empty. Nothing to peek.");
46 |             return -1;
47 |         }
48 |         return arr[front];
49 |     }
50 | 
51 |     public void display() {
52 |         if (isEmpty()) {
53 |             System.out.println("Queue is empty.");
54 |             return;
55 |         }
56 |         System.out.print("Queue: ");
57 |         for (int i = 0; i < size; i++) {
58 |             System.out.print(arr[(front + i) % capacity] + " ");
59 |         }
60 |         System.out.println();
61 |     }
62 | 
63 |     public static void main(String[] args) {
64 |         Queue queue = new Queue(5);
65 |         queue.enqueue(10);
66 |         queue.enqueue(20);
67 |         queue.enqueue(30);
68 |         queue.enqueue(40);
69 |         queue.enqueue(50);
70 |         queue.enqueue(60);
71 | 
72 |         queue.display();
73 | 
74 |         System.out.println("Dequeued: " + queue.dequeue());
75 |         System.out.println("Front element: " + queue.peek());
76 | 
77 |         queue.display();
78 |     }
79 | }
80 | 


--------------------------------------------------------------------------------
/UNI/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 |   "java.debug.settings.onBuildFailureProceed": true
3 | }
4 | 


--------------------------------------------------------------------------------
/UNI/AD_arr_print.java:
--------------------------------------------------------------------------------
 1 | //java array program to print 2d array
 2 | public class AD_arr_print {
 3 |     public static void main(String[] args) {
 4 |         int[][] array = {
 5 |                 { 1, 2, 3 },
 6 |                 { 4, 5, 6 },
 7 |                 { 7, 8, 9 }
 8 |         };
 9 |         for (int i = 0; i < array.length; i++) {
10 |             for (int j = 0; j < array[i].length; j++) {
11 |                 System.out.print(array[i][j] + " ");
12 |             }
13 |             System.out.println();
14 |         }
15 |     }
16 | }
17 | 


--------------------------------------------------------------------------------
/UNI/Abstract_Shape.java:
--------------------------------------------------------------------------------
 1 | 
 2 | abstract class shape {
 3 |     abstract double area();
 4 | 
 5 | }
 6 | 
 7 | class Circle extends shape {
 8 |     double radius;
 9 | 
10 |     Circle(double radius) {
11 |         this.radius = radius;
12 |     }
13 | 
14 |     @Override
15 |     double area() {
16 |         return radius * radius;
17 |     }
18 | }
19 | 
20 | class rectangle extends shape {
21 |     double length, width;
22 | 
23 |     rectangle(double length, double width) {
24 |         this.length = length;
25 |         this.width = width;
26 | 
27 |     }
28 | 
29 |     @Override
30 |     double area() {
31 |         return length * width;
32 |     }
33 | }
34 | 
35 | public class Abstract_Shape {
36 |     public static void main(String[] args) {
37 |         Circle circle = new Circle(65);
38 |         rectangle rectangle = new rectangle(67, 98);
39 |         System.out.println(circle.area());
40 |         System.out.println(rectangle.area());
41 |     }
42 | }


--------------------------------------------------------------------------------
/UNI/Abstract_final.java:
--------------------------------------------------------------------------------
 1 | 
 2 | abstract class Animal {
 3 |     abstract void speak();
 4 | }
 5 | 
 6 | class Dog extends Animal {
 7 |     final int dog_count = 38;
 8 | 
 9 |     @Override
10 |     void speak() {
11 |         System.out.println("The dog barks");
12 |     }
13 | }
14 | 
15 | public class Abstract_final {
16 |     public static void main(String[] args) {
17 |         Dog dog = new Dog();
18 |         dog.speak();
19 |         System.out.println("the dog count is: " + dog.dog_count);
20 |     }
21 | 
22 | }
23 | 


--------------------------------------------------------------------------------
/UNI/Alphabets.java:
--------------------------------------------------------------------------------
1 | // Write a program to print all alphabets from a to z
2 | public class Alphabets {
3 |     public static void main(String[] args) {
4 |         for (char ch = 'a'; ch <= 'z'; ch++) {
5 |             System.out.print(ch + " ");
6 |         }
7 |     }
8 | }


--------------------------------------------------------------------------------
/UNI/Armstrong1000.java:
--------------------------------------------------------------------------------
 1 | 
 2 | //Write a Program to print All Armstrong numbers between 1 to 1000
 3 | public class Armstrong1000 {
 4 |     public static void main(String args[]) {
 5 |         int num1 = 1;
 6 |         int num2 = 1000;
 7 |         for (int i = num1; i < num2; i++) {
 8 |             int check, rem, sum = 0;
 9 |             check = i;
10 |             while (check != 0) {
11 |                 rem = check % 10;
12 |                 sum = sum + (rem * rem * rem);
13 |                 check = check / 10;
14 |             }
15 |             if (sum == i) {
16 |                 System.out.println(i + " is an Armstrong number.");
17 |             }
18 |         }
19 | 
20 |     }
21 | }


--------------------------------------------------------------------------------
/UNI/Array_print_find_big_small.java:
--------------------------------------------------------------------------------
 1 | //WAP to reed and print an array. also find greatest and smallest element in array
 2 | 
 3 | import java.util.Scanner;
 4 | 
 5 | public class Array_print_find_big_small {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter the size of array:");
 9 |         int arrlength = in.nextInt();
10 |         int[] arr = new int[arrlength];
11 |         for (int i = 0; i < arrlength; i++) {
12 |             System.out.print("Enter the data for index " + i + " :");
13 |             arr[i] = in.nextInt();
14 |         }
15 |         for (int i = 0; i < arrlength; i++) {
16 |             System.out.print(arr[i] + ",");
17 | 
18 |         }
19 |         System.out.println();
20 |         int smallele = 0;
21 |         int largeele = 0;
22 |         for (int i = 0; i < arrlength; i++) {
23 |             if (arr[i] > arr[largeele]) {
24 |                 largeele = i;
25 |             }
26 |             if (arr[i] < arr[smallele]) {
27 |                 smallele = i;
28 |             }
29 |         }
30 |         System.out.print(largeele + "  " + smallele);
31 | 
32 |         in.close();
33 |     }
34 | 
35 | }


--------------------------------------------------------------------------------
/UNI/Binary_to_decimal.java:
--------------------------------------------------------------------------------
 1 | 
 2 | // Write a program to convert a binary number into a decimal number without using array, function 
 3 | //and while loop 
 4 | import java.util.Scanner;
 5 | 
 6 | public class Binary_to_decimal {
 7 |     public static void main(String[] args) {
 8 |         Scanner in = new Scanner(System.in);
 9 |         System.out.print("Enter a binary number: ");
10 |         int biNum = in.nextInt();
11 |         int deciNum = 0;
12 |         int power = 0;
13 |         for (int n = biNum; n > 0; n /= 10) {
14 |             int lastDigit = n % 10;
15 |             deciNum += lastDigit * Math.pow(2, power);
16 |             power++;
17 |         }
18 |         System.out.println("Decimal equivalent: " + deciNum);
19 |         in.close();
20 |     }
21 | }


--------------------------------------------------------------------------------
/UNI/Book.java:
--------------------------------------------------------------------------------
 1 | public class Book {
 2 |     String title;
 3 |     String author;
 4 |     int price;
 5 | 
 6 |     Book() {
 7 |         title = "no name";
 8 |         author = "no author";
 9 |         price = 0;
10 |     }
11 | 
12 |     Book(String bookname, String writer, int money) {
13 |         title = bookname;
14 |         author = writer;
15 |         price = money;
16 |     }
17 | }
18 | 
19 | class Run {
20 |     public static void main(String[] args) {
21 |         Book book1 = new Book();
22 |         Book book2 = new Book("rich dad poor dad", "robert kiosaki", 500);
23 |         System.out.println(book1.author);
24 |         System.out.println(book1.price);
25 |         System.out.println(book1.title);
26 |         System.out.println(book2.author);
27 |         System.out.println(book2.price);
28 |         System.out.println(book2.title);
29 |     }
30 | 
31 | }
32 | 


--------------------------------------------------------------------------------
/UNI/CLI_output.java:
--------------------------------------------------------------------------------
1 | //Write a Java program that will accept command-line arguments and display the 
2 | //same
3 | 
4 | public class CLI_output {
5 |     public static void main(String[] args) {
6 |         System.out.print(args[0]);
7 |     }
8 | }
9 | 


--------------------------------------------------------------------------------
/UNI/Calculator.java:
--------------------------------------------------------------------------------
 1 | 
 2 | //Write a Java program to create a simple calculator
 3 | import java.util.Scanner;
 4 | 
 5 | public class Calculator {
 6 |     public static void main(String[] args) {
 7 |         Scanner scanner = new Scanner(System.in);
 8 | 
 9 |         System.out.println("Choose an operator: +, -, *, or /");
10 |         String operator = scanner.next();
11 | 
12 |         System.out.println("Enter 1 no");
13 |         int no1 = scanner.nextInt();
14 |         System.out.println("Enter 2 no");
15 |         int no2 = scanner.nextInt();
16 | 
17 |         switch (operator) {
18 |             case "+":
19 |                 System.out.println(no1 + no2);
20 |                 break;
21 |             case "-":
22 |                 System.out.println(no1 - no2);
23 |                 break;
24 |             case "*":
25 |                 System.out.println(no1 * no2);
26 |                 break;
27 |             case "/":
28 |                 System.out.println(no1 / no2);
29 |                 break;
30 |         }
31 |         scanner.close();
32 | 
33 |     }
34 | 
35 | }
36 | 


--------------------------------------------------------------------------------
/UNI/CheckEquality.java:
--------------------------------------------------------------------------------
 1 | 
 2 | //Write a Java program that accepts three numbers and checks whether All numbers are equal. 
 3 | import java.util.Scanner;
 4 | 
 5 | public class CheckEquality {
 6 |     public static void main(String[] args) {
 7 | 
 8 |         Scanner in = new Scanner(System.in);
 9 | 
10 |         System.out.println("Enter first number:");
11 |         int num1 = in.nextInt();
12 | 
13 |         System.out.println("Enter second number:");
14 |         int num2 = in.nextInt();
15 | 
16 |         System.out.println("Enter third number:");
17 |         int num3 = in.nextInt();
18 | 
19 |         if (num1 == num2 && num2 == num3) {
20 |             System.out.println("Equal");
21 |         } else {
22 |             System.out.println("Not Equal");
23 |         }
24 |         in.close();
25 |     }
26 | }


--------------------------------------------------------------------------------
/UNI/Copy_array.java:
--------------------------------------------------------------------------------
 1 | //java program to copy an array
 2 | public class Copy_array {
 3 |     public static void main(String[] args) {
 4 |         int[] originalArray = { 10, 20, 30, 40, 50 };
 5 |         int[] copiedArray = new int[originalArray.length];
 6 |         for (int i = 0; i < originalArray.length; i++) {
 7 |             copiedArray[i] = originalArray[i];
 8 |             System.out.print(copiedArray[i] + " ");
 9 |         }
10 |     }
11 | }


--------------------------------------------------------------------------------
/UNI/Cricket.java:
--------------------------------------------------------------------------------
 1 | //You're developing a simple scoring system for a cricket match. The match involves 
 2 | //a single over (6 balls) and you're required to record the runs scored on each ball. The system 
 3 | //should also calculate the total runs scored in the over and determine if the over included any 
 4 | //dot balls (a ball where no runs are scored). 
 5 | //Task: 
 6 | //Create a 1-dimensional array to store the runs scored on each of the 6 balls in the over. 
 7 | //Calculate the total runs scored in the over. 
 8 | //Count the number of dot balls (balls where zero runs were scored). 
 9 | //Determine the highest run scored on a single ball. 
10 | //Runs scored in the over (ball by ball): 
11 | //Ball 1: 1 run 
12 | //Ball 2: 4 runs 
13 | //Ball 3: 0 runs (dot ball) 
14 | //Ball 4: 6 runs 
15 | //Ball 5: 2 runs 
16 | //Ball 6: 0 runs (dot ball)
17 | 
18 | import java.util.Scanner;
19 | 
20 | public class Cricket {
21 |     public static void main(String[] args) {
22 |         Scanner in = new Scanner(System.in);
23 |         int dot_ball = 0;
24 |         int total = 0;
25 |         int high = 0;
26 |         int[] arr = new int[6];
27 |         for (int i = 0; i <= 5; i++) {
28 |             System.out.print("Enter score in " + (1 + i) + " ball: ");
29 |             arr[i] = in.nextInt();
30 |         }
31 |         for (int i = 0; i <= 5; i++) {
32 |             total = total + arr[i];
33 |             if (arr[i] == 0) {
34 |                 dot_ball++;
35 |             }
36 |             if (arr[i] > arr[high]) {
37 |                 high = i;
38 |             }
39 |             System.out.print(arr[i] + ",");
40 |         }
41 |         System.out.println();
42 |         System.out.println("Total Score: " + total);
43 |         System.out.println("Total Dot balls: " + dot_ball);
44 |         System.out.println("Highest score in a ball: " + arr[high]);
45 |         in.close();
46 | 
47 |     }
48 | }
49 | 


--------------------------------------------------------------------------------
/UNI/Even_print.java:
--------------------------------------------------------------------------------
1 | // Write a program to print all even numbers between 1 to 100
2 | public class Even_print {
3 |     public static void main(String[] args) {
4 |         for (int i = 2; i <= 100; i += 2) {
5 |             System.out.print(i + " ");
6 |         }
7 |     }
8 | }


--------------------------------------------------------------------------------
/UNI/Even_sum.java:
--------------------------------------------------------------------------------
 1 | 
 2 | // Write a program to find the sum of all even numbers between 1 to n 
 3 | import java.util.Scanner;
 4 | 
 5 | public class Even_sum {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter Number: ");
 9 |         int n = in.nextInt();
10 |         int sum = 0;
11 |         for (int i = 2; i <= n; i += 2) {
12 |             sum += i;
13 |         }
14 |         System.out.print(" Sum: " + sum);
15 |         in.close();
16 |     }
17 | }
18 | 


--------------------------------------------------------------------------------
/UNI/Exception_handling.java:
--------------------------------------------------------------------------------
 1 | import java.util.Scanner;
 2 | 
 3 | public class Exception_handling {
 4 |     public static void main(String[] args) {
 5 |         try {
 6 |             Scanner scanner = new Scanner(System.in);
 7 |             System.out.println("Enter a: ");
 8 |             int a = scanner.nextInt();
 9 |             System.out.println("Enter b: ");
10 |             int b = scanner.nextInt();
11 | 
12 |             int c = a / b;
13 |             System.out.println(c);
14 |         } catch (ArithmeticException e) {
15 |             System.out.println("This is arithematic exception");
16 |         } catch (Exception ex) {
17 |             System.out.println("This is Exception");
18 |         } finally {
19 |             System.out.println("Program executed succesfully");
20 |         }
21 |     }
22 | }
23 | 


--------------------------------------------------------------------------------
/UNI/Fact.java:
--------------------------------------------------------------------------------
 1 | //Write a program to find the factorial value of any number 
 2 | 
 3 | import java.util.Scanner;
 4 | 
 5 | public class Fact {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter the number: ");
 9 |         int number = in.nextInt();
10 |         long fact = 1;
11 |         for (int i = 1; i <= number; i++) {
12 |             fact *= i;
13 |         }
14 |         System.out.println("The fact is " + fact);
15 |         in.close();
16 |     }
17 | }


--------------------------------------------------------------------------------
/UNI/Fibonacci.java:
--------------------------------------------------------------------------------
 1 | 
 2 | //7. To calculate Fibonacci Series up to n numbers.
 3 | import java.util.Scanner;
 4 | 
 5 | public class Fibonacci {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         int n = in.nextInt();
 9 |         int p = 0;
10 |         int i = 1;
11 |         int count = 2;
12 | 
13 |         while (count <= n) {
14 |             int temp = i;
15 |             i = i + p;
16 |             p = temp;
17 |             count++;
18 |         }
19 |         System.out.println(i);
20 |         in.close();
21 |     }
22 | }
23 | 


--------------------------------------------------------------------------------
/UNI/Final_var_used.java:
--------------------------------------------------------------------------------
1 | public class Final_var_used {
2 |     public static void main(String[] args) {
3 |         final double PIE = 3.1415;
4 |         System.out.println("The value of pie is: " + PIE);
5 |     }
6 | }


--------------------------------------------------------------------------------
/UNI/Football.java:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * You are developing a simple application to manage the player lineup for a
 3 |  * football
 4 |  * (soccer) match. The coach needs to maintain a list of the starting 11 players
 5 |  * for the match. After
 6 |  * finalizing the lineup, the coach wants to:
 7 |  * Display the names of all the players in the starting lineup.
 8 |  * Check if a specific player is in the starting lineup.
 9 |  * Update the lineup by replacing a player who got injured during the warm-up
10 |  * with a substitute.
11 |  * Task:
12 |  * Create a String[] array to store the names of the 11 starting players.
13 |  * Implement a method to display all players in the lineup.
14 |  * Implement a method to check if a specific player is in the starting lineup.
15 |  * Implement a method to replace an injured player with a substitute.
16 |  * Starting Lineup:
17 |  * Player 1: John
18 |  * Player 2: David
19 |  * Player 3: Mike
20 |  * Player 4: Chris
21 |  * Player 5: Alex
22 |  * Player 6: Ryan
23 |  * Player 7: James
24 |  * Player 8: Sam
25 |  * Player 9: Robert
26 |  * Player 10: Daniel
27 |  * Player 11: Steve
28 |  * Substitute:
29 |  * Substitute Player: Luke (to replace injured player James)
30 |  */
31 | public class Football {
32 |     static String[] lineup = { "john", "david", "dike", "dhris", "alex", "ayan", "james", "sam", "robert", "daniel",
33 |             "steve" };
34 | 
35 |     public static void main(String[] args) {
36 |         Football f = new Football();
37 |         System.out.println(f.find("john"));
38 |         display();
39 |         change(1);
40 |         display();
41 | 
42 |     }
43 | 
44 |     boolean find(String name) {
45 |         for (String i : lineup) {
46 |             if (i == name) {
47 |                 return true;
48 |             }
49 | 
50 |         }
51 |         return false;
52 |     }
53 | 
54 |     static void display() {
55 |         int j = 1;
56 |         for (String i : lineup) {
57 |             System.out.println("Player " + j + " : " + i);
58 |             j++;
59 |         }
60 |     }
61 | 
62 |     static void change(int num) {
63 |         num--;
64 |         lineup[num] = "luke";
65 |     }
66 | 
67 | }


--------------------------------------------------------------------------------
/UNI/Greeting_Msg.java:
--------------------------------------------------------------------------------
 1 | //Write the following program using if else if ladder. Accept an hour from the user and output
 2 | //the following as indicated below.include the last condition in the else section.
 3 | // 1.Hour greater than or equal to 0 and less than 12.               "Good Morning"
 4 | // 2.Hour greater than or equal to 12 and less than 18.              "Good Afternoon"
 5 | // 3.Hour greater than or equal to 18 and less than 24.              "Good Evening"
 6 | // 4.Any other input .                                               "Time is out of range"  
 7 | 
 8 | import java.util.Scanner;
 9 | 
10 | public class Greeting_Msg {
11 |     public static void main(String[] args) {
12 |         Scanner in = new Scanner(System.in);
13 |         System.out.print("Enter the time:");
14 |         int time = in.nextInt();
15 |         in.close();
16 |         if (time >= 0 && time < 12) {
17 |             System.out.print("Good Morning");
18 |         }
19 | 
20 |         else if (time >= 12 && time < 18) {
21 |             System.out.print("Good Afternoon");
22 |         }
23 | 
24 |         else if (time >= 18 && time <= 24) {
25 |             System.out.print("Good Evening");
26 |         }
27 | 
28 |         else {
29 |             System.out.println("Time is out of range.");
30 |         }
31 | 
32 |     }
33 | }


--------------------------------------------------------------------------------
/UNI/Hello_World.java:
--------------------------------------------------------------------------------
 1 | //WAP to print a message "Hello World"
 2 | 
 3 | public class Hello_World {
 4 | 
 5 |     public static void main(String[] args) {
 6 | 
 7 |         System.out.print("Hello World");
 8 | 
 9 |     }
10 | }


--------------------------------------------------------------------------------
/UNI/Hw.java:
--------------------------------------------------------------------------------
 1 | abstract class Animal {
 2 |     abstract void speak();
 3 | }
 4 | 
 5 | class Dog extends Animal {
 6 |     final int dog_count = 38;
 7 | 
 8 |     @Override
 9 |     void speak() {
10 |         System.out.println("The dog barks");
11 |     }
12 | }
13 | 
14 | public class Abstract_final {
15 |     public static void main(String[] args) {
16 |         Dog dog = new Dog();
17 |         dog.speak();
18 |         System.out.println("the dog count is: " + dog.dog_count);
19 |     }
20 | 
21 | }
22 | 


--------------------------------------------------------------------------------
/UNI/Increasing_order.java:
--------------------------------------------------------------------------------
 1 | 
 2 | //Write a Java program that accepts three numbers from the user and check if the numbers are in 
 3 | //"increasing" or "decreasing" order
 4 | import java.util.Scanner;
 5 | 
 6 | public class Increasing_order {
 7 |     public static void main(String[] args) {
 8 |         Scanner in = new Scanner(System.in);
 9 |         System.out.println("Enter first number:");
10 |         int num1 = in.nextInt();
11 |         System.out.println("Enter second number:");
12 |         int num2 = in.nextInt();
13 |         System.out.println("Enter third number:");
14 |         int num3 = in.nextInt();
15 |         if (num1 < num2 && num2 < num3) {
16 |             System.out.println("increasing order");
17 |         } else if (num1 > num2 && num2 > num3) {
18 |             System.out.println("decreasing order");
19 |         } else {
20 |             System.out.println("neither increasing nor decreasing order");
21 |         }
22 |         in.close();
23 |     }
24 | }
25 | 


--------------------------------------------------------------------------------
/UNI/Largest_element.java:
--------------------------------------------------------------------------------
 1 | //java array program to find the largest element in array
 2 | public class Largest_element {
 3 |     public static void main(String[] args) {
 4 |         int[] arr = { 6, 7, 8, 10, 22, 38 };
 5 |         int largeele = 0;
 6 |         for (int i = 0; i < arr.length; i++) {
 7 |             if (arr[i] > arr[largeele]) {
 8 |                 largeele = i;
 9 |             }
10 |         }
11 |         System.out.println(largeele);
12 |     }
13 | }


--------------------------------------------------------------------------------
/UNI/LibraryFineCalculator.java:
--------------------------------------------------------------------------------
 1 | 
 2 | /*A library charges a fine for every book returned late. For the first 5 days, the fine is 50 paise; 
 3 | for 6-10 days, the fine is one rupee; and above 10 days, the fine is 5 rupees. Your membership 
 4 | will be cancelled if you return the book after 30 days. Write a program to accept the number of 
 5 | days the member is late to return the book and display the fine or the appropriate message */
 6 | import java.util.Scanner;
 7 | 
 8 | public class LibraryFineCalculator {
 9 |     public static void main(String[] args) {
10 |         Scanner in = new Scanner(System.in);
11 | 
12 |         System.out.print("Enter the number of days: ");
13 |         int days = in.nextInt();
14 |         double fine = 0;
15 |         in.close();
16 |         if (days <= 5) {
17 |             fine = days * 0.50;
18 |         } else if (days <= 10) {
19 |             fine = (5 * 0.50) + (days - 5) * 1;
20 |         } else if (days <= 30) {
21 |             fine = (5 * 0.50) + (5 * 1) + (days - 10) * 5;
22 |         } else {
23 |             System.out.println("Your membership is cancelled.");
24 |         }
25 |         System.out.println("The total fine is: Rs. " + fine);
26 | 
27 |     }
28 | }


--------------------------------------------------------------------------------
/UNI/Login_System.java:
--------------------------------------------------------------------------------
 1 | //you are tasked with developing a program that
 2 | //simulates a login system. the user is given
 3 | //three attempts to enter the correct password
 4 | //in intiger formet like 4545. if the user enters
 5 | //the correct password within three attempts,
 6 | //they are granted access. if the user fails to
 7 | //enter the correct password in three attempts,
 8 | //they are locked out
 9 | 
10 | import java.util.Scanner;
11 | 
12 | public class Login_System {
13 |     public static void main(String[] args) {
14 |         Scanner in = new Scanner(System.in);
15 |         int stored_password = 1234;
16 |         int i = 1;
17 |         while (i <= 3) {
18 |             System.out.print("Enter the password:");
19 |             int a = in.nextInt();
20 |             if (a == stored_password) {
21 |                 System.out.println("Access Granted");
22 |                 break;
23 |             } else {
24 |                 System.out.println("Wrong Password");
25 |             }
26 |             i++;
27 |         }
28 |         if (i >= 3) {
29 |             System.out.println("you are locked out");
30 | 
31 |         }
32 |         in.close();
33 |     }
34 | }
35 | 


--------------------------------------------------------------------------------
/UNI/MaxOfThree.java:
--------------------------------------------------------------------------------
 1 | import java.util.Scanner;
 2 | 
 3 | public class MaxOfThree {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter first number:");
 7 |         int a = in.nextInt();
 8 |         System.out.print("Enter second number:");
 9 |         int b = in.nextInt();
10 |         System.out.print("Enter third number:");
11 |         int c = in.nextInt();
12 |         if (a > b && a > c) {
13 |             System.out.println("Largest number is:" + a);
14 |         } else if (b > a && b > c) {
15 |             System.out.println("Largest number is:" + b);
16 |         } else {
17 |             System.out.println("Largest number is:" + c);
18 |         }
19 |         in.close();
20 |     }
21 | }


--------------------------------------------------------------------------------
/UNI/Movie_Theatre.java:
--------------------------------------------------------------------------------
 1 | //A movie theatre has the following ticket pricing rules:
 2 | //children under 12 years old pay $5.
 3 | //seniors 65 years and older pay $7.
 4 | //regular adults (12-64 years old) pay $10.
 5 | //members get a $2 discount on all ticket prices.
 6 | //we'll prompt the user to input their age and whether they have a membership card.
 7 | //based on this input, the program will determine and print the ticket price.
 8 | 
 9 | import java.util.Scanner;
10 | 
11 | public class Movie_Theatre {
12 |     public static void main(String[] args) {
13 |         Scanner in = new Scanner(System.in);
14 |         System.out.print("Enter age:");
15 |         int age = in.nextInt();
16 |         System.out.print("Are you a member? true or false: ");
17 |         boolean member = in.nextBoolean();
18 |         in.close();
19 |         int cost;
20 |         if (age < 12) {
21 |             cost = 5;
22 |         } else if (age >= 12 && age < 65) {
23 |             cost = 10;
24 |         } else {
25 |             cost = 7;
26 |         }
27 |         if (member) {
28 |             cost -= 2;
29 |         }
30 |         System.out.println("The ticket price is " + cost);
31 | 
32 |     }
33 | 
34 | }


--------------------------------------------------------------------------------
/UNI/Multiple_of_5.java:
--------------------------------------------------------------------------------
 1 | //Write a Java program to check whether the given integer is a multiple of 5 
 2 | 
 3 | public class Multiple_of_5 {
 4 |     public static void main(String[] args) {
 5 |         int num = 4533;
 6 |         if (num % 5 == 0) {
 7 |             System.out.println("yes its is multiple of five");
 8 |         } else {
 9 |             System.out.println("no its not");
10 |         }
11 |     }
12 | }


--------------------------------------------------------------------------------
/UNI/NIntegers_sum.java:
--------------------------------------------------------------------------------
 1 | 
 2 | // Write a Java program to Find the addition of N integer numbers 
 3 | import java.util.Scanner;
 4 | 
 5 | public class NIntegers_sum {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         int sum = 0;
 9 |         while (true) {
10 |             int num = in.nextInt();
11 |             if (num == 0) {
12 |                 break;
13 |             }
14 |             sum += num;
15 |         }
16 |         System.out.println("The sum is: " + sum);
17 |         in.close();
18 |     }
19 | }


--------------------------------------------------------------------------------
/UNI/NaturalNumSum.java:
--------------------------------------------------------------------------------
 1 | 
 2 | // Write a program to find the sum of all natural numbers between 1 to n
 3 | import java.util.Scanner;
 4 | 
 5 | public class NaturalNumSum {
 6 |     public static void main(String[] args) {
 7 | 
 8 |         Scanner in = new Scanner(System.in);
 9 |         System.out.print("Enter a number: ");
10 |         int n = in.nextInt();
11 |         int sum = 0;
12 |         for (int i = 1; i <= n; i++) {
13 |             sum += i;
14 |         }
15 |         System.out.print("sum: " + sum);
16 |         in.close();
17 |     }
18 | }
19 | 


--------------------------------------------------------------------------------
/UNI/NaturalNumbers.java:
--------------------------------------------------------------------------------
 1 | 
 2 | //Write a program to print all natural numbers from 1 to n
 3 | import java.util.Scanner;
 4 | 
 5 | public class NaturalNumbers {
 6 |     public static void main(String[] args) {
 7 | 
 8 |         Scanner in = new Scanner(System.in);
 9 |         System.out.print("Enter a number: ");
10 |         int n = in.nextInt();
11 | 
12 |         for (int i = 1; i <= n; i++) {
13 |             System.out.print(i + " ");
14 |         }
15 |         in.close();
16 |     }
17 | }
18 | 


--------------------------------------------------------------------------------
/UNI/Number_of_digit.java:
--------------------------------------------------------------------------------
 1 | 
 2 | //Write a Java program that reads a positive integer and counts the number of digits. 
 3 | import java.util.Scanner;
 4 | 
 5 | public class Number_of_digit {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter positive number: ");
 9 |         int number = in.nextInt();
10 |         int digitCount = 0;
11 |         int temp = number;
12 |         while (temp > 0) {
13 |             temp /= 10;
14 |             digitCount++;
15 |         }
16 |         System.out.println("The number of digits is: " + digitCount);
17 |         in.close();
18 |     }
19 | }
20 | 


--------------------------------------------------------------------------------
/UNI/Odd_even_check.java:
--------------------------------------------------------------------------------
 1 | /*1. Write a program to print whether a number is even or odd, also take
 2 | input from the user.*/
 3 | import java.util.Scanner;
 4 | public class Odd_even_check {
 5 |     public static void main(String[] args) {
 6 |         Scanner in = new Scanner(System.in);
 7 |         int num = in.nextInt();
 8 |         if (num % 2 == 0) {
 9 |             System.out.println("The Number is Even");
10 |         }
11 |         else{
12 |             System.out.println("The Number is Odd");
13 |             in.close();
14 |         } 
15 |     }
16 |     
17 | }
18 | 


--------------------------------------------------------------------------------
/UNI/Odd_print.java:
--------------------------------------------------------------------------------
1 | // Write a program to print all odd numbers between 1 to 100
2 | public class Odd_print {
3 |     public static void main(String[] args) {
4 |         for (int i = 1; i <= 100; i += 2) {
5 |             System.out.print(i + " ");
6 |         }
7 |     }
8 | }


--------------------------------------------------------------------------------
/UNI/Odd_sum.java:
--------------------------------------------------------------------------------
 1 | 
 2 | // Write a program to find the sum of all odd numbers between 1 to n 
 3 | import java.util.Scanner;
 4 | 
 5 | public class Odd_sum {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter Number: ");
 9 |         int n = in.nextInt();
10 |         int sum = 0;
11 |         for (int i = 1; i <= n; i += 2) {
12 |             sum += i;
13 |         }
14 |         System.out.print("sum: " + sum);
15 |         in.close();
16 |     }
17 | }


--------------------------------------------------------------------------------
/UNI/Override.java:
--------------------------------------------------------------------------------
 1 | class Animal {
 2 |     void speak() {
 3 |         System.out.println("Animal make sound");
 4 |     }
 5 | }
 6 | 
 7 | class Dog extends Animal {
 8 |     @Override
 9 |     void speak() {
10 |         System.out.println("Dog barks");
11 |     }
12 | }
13 | 
14 | public class Override {
15 |     public static void main(String[] args) {
16 |         Dog dog1 = new Dog();
17 |         dog1.speak();
18 |     }
19 | }


--------------------------------------------------------------------------------
/UNI/Pat_Print.java:
--------------------------------------------------------------------------------
 1 | // 11111
 2 | // 12111
 3 | // 11311
 4 | // 11141
 5 | // 11115
 6 | 
 7 | public class Pat_Print {
 8 |     public static void main(String[] args) {
 9 |         int size = 5;
10 |         for (int i = 0; i < size; i++) {
11 | 
12 |             for (int j = 0; j < size; j++) {
13 | 
14 |                 if (i == j) {
15 |                     System.out.print((i + 1));
16 |                 } else {
17 |                     System.out.print("1");
18 |                 }
19 |             }
20 | 
21 |             System.out.println();
22 |         }
23 |     }
24 | }
25 | 


--------------------------------------------------------------------------------
/UNI/Power.java:
--------------------------------------------------------------------------------
 1 | 
 2 | // Write a program to find the value of one number raised to the power of another
 3 | import java.util.Scanner;
 4 | 
 5 | public class Power {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter base: ");
 9 |         double base = in.nextDouble();
10 |         System.out.print("Enter exponent: ");
11 |         double exponent = in.nextDouble();
12 |         double result = Math.pow(base, exponent);
13 |         System.out.println(result);
14 |         in.close();
15 |     }
16 | }


--------------------------------------------------------------------------------
/UNI/Previous_year_paper_question.java:
--------------------------------------------------------------------------------
 1 | public class Previous_year_paper_question {
 2 |     static int a = 20;
 3 | 
 4 |     Previous_year_paper_question() {
 5 |         a = 200;
 6 |     }
 7 | 
 8 |     public static void main(String[] args) {
 9 |         new Previous_year_paper_question();
10 |         System.out.println(a);
11 |     }
12 | }
13 | 


--------------------------------------------------------------------------------
/UNI/Prime_Check.java:
--------------------------------------------------------------------------------
 1 | import java.util.Scanner;
 2 | 
 3 | public class Prime_Check {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter the number:");
 7 |         int num = in.nextInt();
 8 |         in.close();
 9 | 
10 |         int count = 0;
11 |         if (num <= 1 || num <= 0) {
12 |             System.out.println("The number is not prime");
13 |         } else {
14 |             for (int i = 2; i == num; i++) {
15 |                 if (num % i == 0) {
16 |                     count = 1;
17 |                 }
18 |             }
19 |         }
20 |         if (count == 1) {
21 |             System.out.println("The number is prime");
22 |         } else {
23 |             System.out.println("The number is not prime");
24 |         }
25 |     }
26 | }
27 | 


--------------------------------------------------------------------------------
/UNI/Rectangle.java:
--------------------------------------------------------------------------------
 1 | import java.util.Scanner;
 2 | 
 3 | public class Rectangle {
 4 |     double length = 0;
 5 |     double width = 0;
 6 |     double area = 0;
 7 |     Scanner in = new Scanner(System.in);
 8 | 
 9 |     void fill() {
10 |         System.out.print("Enter Length: ");
11 |         length = in.nextDouble();
12 |         System.out.println();
13 |         System.out.print("Enter Width: ");
14 |         width = in.nextDouble();
15 |     }
16 | 
17 |     void calarea() {
18 |         area = length * width;
19 |     }
20 | 
21 |     void print() {
22 |         calarea();
23 |         System.out.println("Length: " + length);
24 |         System.out.println("Width: " + width);
25 |         System.out.println("Area: " + area);
26 |     }
27 | 
28 |     public static void main(String[] args) {
29 |         Rectangle abc = new Rectangle();
30 |         abc.fill();
31 |         abc.print();
32 |     }
33 | }


--------------------------------------------------------------------------------
/UNI/ReverseNaturalNumbers.java:
--------------------------------------------------------------------------------
 1 | 
 2 | // Write a program to print all natural numbers in reverse 
 3 | import java.util.Scanner;
 4 | 
 5 | public class ReverseNaturalNumbers {
 6 |     public static void main(String[] args) {
 7 | 
 8 |         Scanner in = new Scanner(System.in);
 9 | 
10 |         System.out.print("Enter a number: ");
11 |         int n = in.nextInt();
12 | 
13 |         for (int i = n; i >= 1; i--) {
14 |             System.out.print(i + " ");
15 |         }
16 | 
17 |         in.close();
18 |     }
19 | }


--------------------------------------------------------------------------------
/UNI/ReverseNumberCheck.java:
--------------------------------------------------------------------------------
 1 | //A five-digit number is entered through the keyboard. Write a program to obtain the reversed 
 2 | //number and determine whether the original and reversed numbers are equal.
 3 | 
 4 | import java.util.Scanner;
 5 | 
 6 | public class ReverseNumberCheck {
 7 |     public static void main(String[] args) {
 8 |         Scanner in = new Scanner(System.in);
 9 | 
10 |         System.out.print("Enter number: ");
11 |         int number = in.nextInt();
12 | 
13 |         int temp = number;
14 |         int revNum = 0;
15 | 
16 |         while (temp != 0) {
17 |             int lastDigit = temp % 10;
18 |             revNum = revNum * 10 + lastDigit;
19 |             temp /= 10;
20 |         }
21 |         System.out.println("Reversed Number: " + revNum);
22 | 
23 |         if (number == revNum) {
24 |             System.out.println("Equal.");
25 |         } else {
26 |             System.out.println("Not Equal.");
27 |         }
28 |         in.close();
29 |     }
30 | }


--------------------------------------------------------------------------------
/UNI/Reverse_Digit.java:
--------------------------------------------------------------------------------
 1 | 
 2 | // write a program to reverse the given Digits
 3 | import java.util.Scanner;
 4 | 
 5 | public class Reverse_Digit {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 | 
 9 |         System.out.print("Enter a number: ");
10 |         int number = in.nextInt();
11 | 
12 |         int revNum = 0;
13 |         int remainder;
14 | 
15 |         while (number != 0) {
16 |             remainder = number % 10;
17 |             revNum = revNum * 10 + remainder;
18 |             number /= 10;
19 |         }
20 |         System.out.println("Reversed number: " + revNum);
21 |         in.close();
22 |     }
23 | }


--------------------------------------------------------------------------------
/UNI/Star_Pattern.java:
--------------------------------------------------------------------------------
 1 | //Pattern of stars using loops
 2 | /*     *
 3 |  *     **
 4 |  *     ***
 5 |  *     ****
 6 |  *     *****
 7 |  */
 8 | 
 9 | public class Star_Pattern {
10 |     public static void main(String[] args) {
11 |         int n = 4;
12 |         for (int i = 0; i <= n; i++) {
13 | 
14 |             for (int j = 0; j <= i; j++) {
15 |                 System.out.print("*");
16 | 
17 |             }
18 |             System.out.println();
19 |         }
20 |     }
21 | }
22 | 


--------------------------------------------------------------------------------
/UNI/Static_keyword.java:
--------------------------------------------------------------------------------
 1 | 
 2 | public class Static_keyword {
 3 |     static int a = 0;
 4 |     int b;
 5 | 
 6 |     Static_keyword(int b) {
 7 |         a++;
 8 |         this.b = b;
 9 | 
10 |     }
11 | 
12 | }
13 | 
14 | class run {
15 |     public static void main(String[] args) {
16 |         System.out.println(Static_keyword.a);
17 |         Static_keyword abc = new Static_keyword(20);
18 |         System.out.println(abc.a);
19 |         Static_keyword abc2 = new Static_keyword(33);
20 |         System.out.println(abc2.a);
21 |         System.out.println(abc.a);
22 | 
23 |     }
24 | }
25 | 


--------------------------------------------------------------------------------
/UNI/Switch_Case_Week.java:
--------------------------------------------------------------------------------
 1 | //create a program using switch case statement to identify the day of the week.
 2 | 
 3 | import java.util.Scanner;
 4 | 
 5 | public class Switch_Case_Week {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter the day:");
 9 |         String day = in.nextLine();
10 |         in.close();
11 |         switch (day) {
12 |             case "monday":
13 |                 System.out.print("Monday");
14 |                 break;
15 |             case "tuesday":
16 |                 System.out.print("tuesday");
17 |                 break;
18 |             case "wednesday":
19 |                 System.out.print("wednesday");
20 |                 break;
21 |             case "thursday":
22 |                 System.out.print("thursday");
23 |                 break;
24 |             case "friday":
25 |                 System.out.print("friday yoooooohoooooo");
26 |                 break;
27 |             case "saturday":
28 |                 System.out.print("saturday");
29 |                 break;
30 |             case "sunday":
31 |                 System.out.print("sunday");
32 |                 break;
33 |         }
34 |     }
35 | }
36 | 


--------------------------------------------------------------------------------
/UNI/Switch_Case_Weekday.java:
--------------------------------------------------------------------------------
 1 | //create a program using switch case statement to identify the day of the week.
 2 | 
 3 | import java.util.Scanner;
 4 | 
 5 | public class Switch_Case_Weekday {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 |         System.out.print("Enter the day:");
 9 |         String day = in.nextLine();
10 |         in.close();
11 |         switch (day) {
12 |             case "monday":
13 |                 System.out.print("Monday");
14 |                 break;
15 |             case "tuesday":
16 |                 System.out.print("tuesday");
17 |                 break;
18 |             case "wednesday":
19 |                 System.out.print("wednesday");
20 |                 break;
21 |             case "thursday":
22 |                 System.out.print("thursday");
23 |                 break;
24 |             case "friday":
25 |                 System.out.print("friday yoooooohoooooo");
26 |                 break;
27 |             case "saturday":
28 |                 System.out.print("saturday");
29 |                 break;
30 |             case "sunday":
31 |                 System.out.print("sunday");
32 |                 break;
33 |         }
34 |     }
35 | }


--------------------------------------------------------------------------------
/UNI/Table.java:
--------------------------------------------------------------------------------
 1 | 
 2 | // Write a program to print tables
 3 | import java.util.Scanner;
 4 | 
 5 | public class Table {
 6 |     public static void main(String[] args) {
 7 |         Scanner in = new Scanner(System.in);
 8 | 
 9 |         System.out.print("Enter number: ");
10 |         int number = in.nextInt();
11 | 
12 |         for (int i = 1; i <= 10; i++) {
13 |             System.out.println(number + " x " + i + " = " + (number * i));
14 |         }
15 | 
16 |         in.close();
17 |     }
18 | }
19 | 


--------------------------------------------------------------------------------
/UNI/Two_metrics_areequal.java:
--------------------------------------------------------------------------------
 1 | public class Two_metrics_areequal {
 2 |     public static void main(String[] args) {
 3 | 
 4 |         int[][] m1 = {
 5 |                 { 1, 2, 3 },
 6 |                 { 4, 5, 6 },
 7 |                 { 7, 8, 9 }
 8 |         };
 9 |         int[][] m2 = {
10 |                 { 1, 2, 3 },
11 |                 { 4, 5, 6 },
12 |                 { 7, 8, 9 }
13 |         };
14 |         boolean areEqual = true;
15 |         if (m1.length != m2.length || m1[0].length != m2[0].length) {
16 |             areEqual = false;
17 |         } else {
18 |             for (int i = 0; i < m1.length; i++) {
19 |                 for (int j = 0; j < m1[i].length; j++) {
20 |                     if (m1[i][j] != m2[i][j]) {
21 |                         areEqual = false;
22 |                         break;
23 |                     }
24 |                 }
25 |                 if (!areEqual) {
26 |                     break;
27 |                 }
28 |             }
29 |         }
30 |         if (areEqual) {
31 |             System.out.println("The matrices are equal.");
32 |         } else {
33 |             System.out.println("The matrices are not equal.");
34 |         }
35 |     }
36 | }


--------------------------------------------------------------------------------
/UNI/WorkerEfficiency.java:
--------------------------------------------------------------------------------
 1 | 
 2 | /*In a company, worker efficiency is determined based on the time required for a worker to 
 3 |  complete a particular job. If the time taken by the worker is between 2 – 3 hours, then the worker 
 4 |  is said to be highly efficient. If the time required by the worker is between 3 – 4 hours, then the 
 5 |  worker is ordered to improve speed. If the time taken is between 4 – 5 hours, the worker is given 
 6 |  training to improve his speed, and if the time taken by the worker is more than 5 hours, then the 
 7 |  worker has to leave the company. If the time taken by the worker is input through the keyboard, 
 8 |  find the worker's efficiency. 
 9 | */
10 | import java.util.Scanner;
11 | 
12 | public class WorkerEfficiency {
13 |     public static void main(String[] args) {
14 | 
15 |         Scanner in = new Scanner(System.in);
16 | 
17 |         System.out.print("Enter time taken by worker in hours: ");
18 |         double time = in.nextDouble();
19 | 
20 |         if (time >= 2 && time <= 3) {
21 |             System.out.println("worker is highly efficient.");
22 |         } else if (time > 3 && time <= 4) {
23 |             System.out.println("worker needs to improve speed.");
24 |         } else if (time > 4 && time <= 5) {
25 |             System.out.println("worker needs training");
26 |         } else {
27 |             System.out.println("worker need to leave");
28 |         }
29 |         in.close();
30 |     }
31 | }


--------------------------------------------------------------------------------
/Usd_to_inr.java:
--------------------------------------------------------------------------------
 1 | //6. Input currency in rupees and output in USD.
 2 | import java.util.Scanner;
 3 | 
 4 | public class Usd_to_inr {
 5 |     public static void main(String[] args) {
 6 |         Scanner in = new Scanner(System.in);
 7 |         System.out.print("Please enter the latest USD rate:");
 8 |         float usd = in.nextFloat();
 9 |         System.out.print("Please enter the amount:");
10 |         float inr = in.nextFloat();
11 |         float amount = usd*inr;
12 |         System.out.println(amount);
13 |         in.close();
14 | 
15 |         
16 |     }
17 | }
18 | 


--------------------------------------------------------------------------------
/Volume_Of_Cone.java:
--------------------------------------------------------------------------------
 1 | //volume of cone
 2 | import java.util.Scanner;
 3 | public class Volume_Of_Cone {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter radius:");
 7 |         double R = in.nextDouble();
 8 |         System.out.print("Enter height:");
 9 |         double H = in.nextDouble();
10 |         System.out.println(3.14*R*R*(H/3));
11 |         in.close();
12 |     }
13 |     
14 | }
15 | 


--------------------------------------------------------------------------------
/Volume_Of_Cylinder.java:
--------------------------------------------------------------------------------
 1 | //16. Volume Of Cylinder
 2 | import java.util.Scanner;
 3 | public class Volume_Of_Cylinder {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter radius:");
 7 |         double R = in.nextDouble();
 8 |         System.out.print("Enter height:");
 9 |         double H = in.nextDouble();
10 |         System.out.println(3.141592653589793238462643383279502884197*R*R*H);
11 |         in.close();
12 |     }
13 | }
14 | 


--------------------------------------------------------------------------------
/Volume_Of_Prism.java:
--------------------------------------------------------------------------------
 1 | //15. Volume Of Prism
 2 | import java.util.Scanner;
 3 | public class Volume_Of_Prism {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter base:");
 7 |         double B = in.nextDouble();
 8 |         System.out.print("Enter base:");
 9 |         double H = in.nextDouble();
10 |         System.out.println(B*H);
11 |         in.close();
12 |     }
13 | }
14 | 


--------------------------------------------------------------------------------
/Volume_Of_Pyramid.java:
--------------------------------------------------------------------------------
 1 | //18. Volume Of Pyramid
 2 | import java.util.Scanner;
 3 | public class Volume_Of_Pyramid {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter base length:");
 7 |         double basel = in.nextDouble();
 8 |         System.out.print("Enter base width:");
 9 |         double basew = in.nextDouble();
10 |         System.out.print("Enter height:");
11 |         double height = in.nextDouble();
12 |         double volume = (basel*basew*height)/3;
13 |         System.out.println(volume);
14 |         in.close();
15 |     }  
16 | }


--------------------------------------------------------------------------------
/Volume_Of_Sphere.java:
--------------------------------------------------------------------------------
 1 | //17. Volume Of Sphere
 2 | import java.util.Scanner;
 3 | public class Volume_Of_Sphere {
 4 |     public static void main(String[] args) {
 5 |         Scanner in = new Scanner(System.in);
 6 |         System.out.print("Enter radius:");
 7 |         double R = in.nextDouble();
 8 |         System.out.println(1.3333333333*(3.1415926535897932384*(R*R*R)));
 9 |         in.close();
10 |     }
11 | }
12 | 


--------------------------------------------------------------------------------
/Vote_method.java:
--------------------------------------------------------------------------------
 1 | /*3. [A person is eligible to vote if his/her age is greater than or equal to 18. 
 2 | Define a method to find out if he/she is eligible to vote.]
 3 | (https://www.efaculty.in/java-programs/voting-age-program-in-java/)*/
 4 | 
 5 | import java.util.Scanner;
 6 | public class Vote_method {
 7 |     public static void main(String[] args) {
 8 |         Scanner in = new Scanner(System.in);
 9 |         System.out.print("Enter age:");
10 |         int age = in.nextInt();
11 |         in.close();
12 |         System.out.println(check(age));
13 |     }
14 |     static String check (int age){
15 |         String msg;
16 |         if(age >=18){
17 |             msg = "He/She can vote";
18 |         }
19 |         else {
20 |             msg = "He/She cannot vote";
21 |         }
22 |         return msg;
23 |     }
24 | }
25 | 


--------------------------------------------------------------------------------
/Vowel_check.java:
--------------------------------------------------------------------------------
 1 | public class Vowel_check {
 2 | 
 3 |     public static void main(String[] args) {
 4 | 
 5 |         char ch = 'z';
 6 | 
 7 |         switch (ch) {
 8 |             case 'a':
 9 |             case 'e':
10 |             case 'i':
11 |             case 'o':
12 |             case 'u':
13 |                 System.out.println(ch + " is vowel");
14 |                 break;
15 |             default:
16 |                 System.out.println(ch + " is consonant");
17 |                                 
18 |         }
19 |     }
20 | }


--------------------------------------------------------------------------------