Snippets Collections
import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
    public static String findBinary(int num, String result) {
        if(num == 0)
            return result;
        
        result = num % 2 + result;
        return findBinary(num / 2, result);
    } 
	public static void main (String[] args) throws java.lang.Exception
	{
		System.out.println(findBinary(12, ""));

	}
}
import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
    public static boolean isPalindrome(String str) {
        if(str.length() == 0 || str.length() == 1)
            return true;
        
        if(str.charAt(0) == str.charAt(str.length() - 1))
            return isPalindrome(str.substring(1, str.length() - 1));
        
        return false;
        
    }
	public static void main (String[] args) throws java.lang.Exception
	{
		System.out.println(isPalindrome("abcba"));

	}
}
import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
    public static String reverse(String input) {
        if(input.equals(""))
            return "";
        return reverse(input.substring(1)) + input.charAt(0);
    }
	public static void main (String[] args) throws java.lang.Exception
	{
	    
	   System.out.println(reverse("hello"));
	}
}
import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
    public static int recursiveSum(int num) {
        if(num <= 1)
            return num;
        
        return num + recursiveSum(num - 1);
        
    }
	public static void main (String[] args) throws java.lang.Exception
	{
		System.out.println(recursiveSum(10));

	}
}


// -----------------------------------------------------------
$A.get("e.force:navigateToURL").setParams(
    {"url": "/apex/pageName?id=00141000004jkU0AAI"}).fire();
$A.get("e.force:navigateToURL").setParams({"url": "/apex/pageName"}).fire();
import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
    public static void mergeSort(int[] data, int start, int end) {
        if(start < end) {
            int mid = (start + end) / 2;
            mergeSort(data, start, mid);
            mergeSort(data, mid + 1, end);
            merge(data, start, mid, end);
        }
    }
    public static void merge(int[] data, int start, int mid, int end) {
        int[] temp = new int[end - start + 1];
        System.out.println(start +" "+ mid +" "+end);
        
        // i --> starting of left subarray, j--> starting of right subarray
        // mid --> Ending of left subarray, end--> Ending of right subarray
        // k--> pointer for temp array
        int i = start, j = mid + 1, k = 0;
        
        // Ist merge i.e both left and right subarrays have values 
        while(i <= mid && j <= end) {
            if(data[i] <= data[j]) 
                temp[k++] = data[i++];
            else    
                temp[k++] = data[j++];
        }
        
        // 2nd merge i.e run only when left subrray is remaining to be merged
        // and right subrray is done with merging
        while(i <= mid) {
            temp[k++] = data[i++];
        }
        
        // 2nd merge i.e run only when right subrray is remaining to be merged
        // and left subrray is done with merging
        while(j <= end) {
            temp[k++] = data[j++];
        }
        
        // putting back sorted values from temp into the original array
        for(i = start; i <= end; i++) {
            data[i] = temp[i - start];
        }
        
    }
	public static void main (String[] args) throws java.lang.Exception
	{
	    int data[] = {38, 27, 43, 3, 9, 82, 10};
		mergeSort(data, 0 , data.length - 1);
		for(int num : data) {
		    System.out.print(num +" ");
		}

	}
}
Employee.java

public class Employee {
    private String cnic;
    private String name;
    private double salary;

    public Employee() {
        System.out.println("No-argument constructor called");
    }

    public Employee(String cnic, String name) {
        setCnic(cnic);
        setName(name);
    }

    public Employee(String cnic, String name, double salary) {
        this(cnic,name);
        setSalary(salary);
    }

    public String getCnic() {
        return cnic;
    }

    public void setCnic(String cnic) {
        this.cnic = cnic;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public void getEmployee(){
        System.out.println("CNIC: " + cnic);
        System.out.println("Name: " + name);
        System.out.println("Salary: " + salary);
    }
}

///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////

EmployeeTest.java

public class EmployeeTest {
    public static void main(String[] args) {
        System.out.println();
        Employee employee1 = new Employee();
        Employee employee2 = new Employee("34104-1234567-9","Muhammad Abdul Rehman");
        Employee employee3 = new Employee("34104-9876543-2","Ahmad",100000);


        employee1.getEmployee();
        System.out.println("----------------");
        employee2.getEmployee();
        System.out.println("-----------------");
        employee3.getEmployee();
        System.out.println("-----------------");
    }

}

public boolean isPowerOfFour(int n) {
        // If a number is power of 2, It will have 1 bit at even position and if its a power of 4, 
        // which is not a power of 2 e.g. 128 it will have 1 bit at odd position.

        return (n >0) && ((n &(n-1)) ==0) && ((n & 0xaaaaaaaa) ==0);
        
    }
public String addBinary(String a, String b) {
       BigInteger num1 = new BigInteger(a,2);
       BigInteger num2 = new BigInteger(b,2);
       BigInteger zero = new BigInteger("0",2);
       BigInteger carry, answer;
       while(!num2.equals(zero)) {
        answer = num1.xor(num2);
        carry = num1.and(num2).shiftLeft(1);
        num1 = answer;
        num2 = carry;
       }
        return num1.toString(2);
    }
public char findTheDifference(String s, String t) {
        char ch =0;
        for(int i=0; i<s.length(); i++) {
            ch ^= s.charAt(i);
        }
        for(int i=0; i<t.length(); i++) {
            ch ^= t.charAt(i);
        }
        return ch;
    }
 if (num == 0) {
            return 1;
        }

        int bitCount = (int) Math.floor((int)(Math.log(num) / Math.log(2))) + 1;
        int allBitsSet = (1 << bitCount) - 1;
        return num ^ allBitsSet;
 // find number of 1 bits
        int n = 10; //101
        int count =0;
        // will repeatedly do and of number with(n-1), as this flips the LSB 1 bit
        while(n !=0) {
            count++;
            n &= (n-1);

        }
        System.out.println("count is " + count);
// creating a monotonic stack
        int[] arr = new int[]{1,2,6,3,5,9, 11,7,};
        Deque<Integer> stack = new LinkedList<>();
        for(int i=0; i<arr.length; i++) {
            while(!stack.isEmpty() && stack.peek()< arr[i]) {
                stack.pop();
            }
            stack.push(arr[i]);
        }
        System.out.println("stack is " + stack);
// converting binary to decimal
        int[] n = new int[]{1, 0, 0, 0, 0};
        int num = 0;
        for (int i = 0; i < n.length; i++)
        {
            num = (num<<1) | n[i];
        }
        System.out.println(num);
    
Circle.java

public class Circle{
	private double radius;
	
	public Circle(double radius){
		if(radius > 0){
			this.radius = radius;
		}
		else{
			System.out.println("Invalid radius value.Radius value must be greater than 0.");
		}
	}
	
	public double getRadius(){
		return radius;
	}
	
	public void setRadius(double radius){
		if(radius > 0){
			this.radius = radius;
		}
		else{
			System.out.println("Invalid radius value.Radius value must be greater than 0.");
		}
	}
	
	public double calculateArea(){
		return Math.PI * radius * radius;
	}
	
	public double calculatePerimeter(){
		return 2 * Math.PI * radius;
	}	
}

/////////////////////////////////////////////
////////////////////////////////////////////

TestCircle.java

public class TestCircle{
	
	public static void main(String args[]){
		
		Circle circle = new Circle(5);
		
		System.out.println("Radius: " + circle.getRadius());
		System.out.printf("Area: %.2f\n" , circle.calculateArea());
		System.out.printf("Perimeter: %.2f\n" , circle.calculatePerimeter());
		
		circle.setRadius(8);
		
		System.out.println("Updated Radius: " + circle.getRadius());
		System.out.printf("Updated Area: %.2f\n" , circle.calculateArea());
		System.out.printf("Updated Perimeter: %.2f\n" , circle.calculatePerimeter());
		
		circle.setRadius(-3);
		
		
	}
	
}
/*
 * This Java source file was generated by the Gradle 'init' task.
 */
package gradleproject2;

import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.font.PDType1Font;
import org.apache.pdfbox.pdmodel.font.Standard14Fonts;

public class App {

    public String getGreeting() {
        return "Hello World!";
    }

    public static void main(String[] args) throws IOException {
        // System.out.println(new App().getGreeting());

        //Creating PDF document object 
        PDDocument document = new PDDocument();

        for (int i = 0; i < 10; i++) {
            //Creating a blank page 
            PDPage blankPage = new PDPage();

            PDPageContentStream contentStream = new PDPageContentStream(document, blankPage);

            contentStream.setFont(new PDType1Font(Standard14Fonts.FontName.HELVETICA_BOLD), 12);

            // Add text to the page
            contentStream.beginText();

            contentStream.newLineAtOffset(100, 700);

            contentStream.showText("Hello World, how are you !");

            contentStream.endText();

            //Adding the blank page to the document
            document.addPage(blankPage);
            contentStream.close();
        }

        //Saving the document
        document.save("C:/Users/chachou/Desktop/test java/javageneratepdf.pdf");
        System.out.println("PDF created");
        
      
        //Closing the document
        document.close();
    }
}
BankAccount.java

import java.util.Scanner;

public class BankAccount {
    String name;
	private double balance;
	private int depositCount = 0;
	private int withdrawCount = 0;
	private String accountType;
	
	
	public void deposit(double amount){
		balance += amount;
		System.out.println(amount + " is successfully Deposited");
		depositCount++;
		if(balance > 100000){
			balance = balance + (amount / 100);
		}
	}
	public void setAccountType(String type){
		this.accountType = type;
	}
	
	public void withdraw(double amount){
		if(balance >= amount){
			if(balance - amount < 50000){
				System.out.println("Asre you sure you want to withdraw, it would make your balance below 50,000");
				System.out.println("Press 1 to continue and 0 to abort");
				Scanner input = new Scanner(System.in);
				int confirm = input.nextInt();
				if(confirm != 1){
					System.out.println("Withdrawal aborted");
					return;
				}
			}
			double withdrawAmount = amount;
			if(balance < 50000){
				withdrawAmount = withdrawAmount + amount * 0.02;
				withdrawCount++;
			}
			balance = balance - withdrawAmount;
			System.out.println(withdrawAmount + " is successfully withdrawn");
			
		}
		else{
			System.out.println("Insufficient funds");
		}
			
	}
	public double getBalance(){
		return balance;
	}
	
	public void subscribeSmsAlert(){
		if(accountType.equals("STANDARD")){
			balance -= 2000;
		}
	}
	
	public void subscribeDebitCard(){
		if(accountType.equals("STANDARD")){
			balance -= 5000;
		}
	}
	
	
	void transaction(){
		System.out.println("Account title: " + name);
		System.out.println("Total deposit: " + depositCount);
		System.out.println("Total withdraw: " + withdrawCount);
		System.out.println("Balance: " + balance);
	}
	
}

//////////////////////////////////////////////////////////////////////////////////////

//BankAccountTest.Java

import java.util.Scanner;

public class BankAccountTest{
	
	public static void main(String args[]){
		
		BankAccount account = new BankAccount();
		
		Scanner input = new Scanner(System.in);
		account.name = "Maan";
		
		System.out.println("Enter the account type: ");
		String accountType = input.nextLine();
		account.setAccountType(accountType);
		
		System.out.println("Do want to subscribe SMS alerts(Y or N): ");
		String sms = input.nextLine();
		if(sms.equals("Y") || sms.equals("y")){
			account.subscribeSmsAlert();
		}
		System.out.println("Do you want to subscribe Debit Card(Y or N): ");
		String debit = input.nextLine();
		
		if(debit.equals("Y") || debit.equals("y")){
			account.subscribeDebitCard();
		}
		
		int choice;
		
		do{
			System.out.println("Press 1: To Deposit an amount\nPress 2: To Withdraw an amount\nPress 3: To View the current balance\nPress 4: To Close the program");
		    choice = input.nextInt();
		
		    switch(choice){
			case 1:
			System.out.println("Enter the amount you want to Deposite");
			double depositeAmount = input.nextDouble(); 
			account.deposit(depositeAmount);
			break;
			case 2:
			System.out.println("Enter the amount you want to withdraw");
			double withdrawAmount = input.nextDouble();
			account.withdraw(withdrawAmount);
			break;
			case 3:
			System.out.println("Your current balance is " + account.getBalance());
			break;
			case 4:
			System.out.println("The program is terminated");
			account.transaction();
			break;
			default:
			System.out.println("Incorrect choice. Please try again!");
			break;
			
		
		}
		
	}while(choice!=4);
  }
	
}
 String paragraph = "bob ,,, %&*lonlaskhdfshkfhskfh,,@!~";
            String normalized = paragraph.replaceAll("[^a-zA-Z0-9]", " ");

// replacing multiple spaces with single space

 String normalized = paragraph.replaceAll("[ ]+", " ");
BankAccount.java

import java.util.Scanner;

public class BankAccount {
    String name;
	private double balance;
	private int depositCount = 0;
	private int withdrawCount = 0;
	
	public void deposit(double amount){
		balance += amount;
		System.out.println(amount + " is successfully Deposited");
		depositCount++;
		if(balance > 100000){
			balance = balance + (amount / 100);
		}
	}
	public void withdraw(double amount){
		if(balance >= amount){
			if(balance - amount < 50000){
				System.out.println("Asre you sure you want to withdraw, it would make your balance below 50,000");
				System.out.println("Press 1 to continue and 0 to abort");
				Scanner input = new Scanner(System.in);
				int confirm = input.nextInt();
				if(confirm != 1){
					System.out.println("Withdrawal aborted");
					return;
				}
			}
			double withdrawAmount = amount;
			if(balance < 50000){
				withdrawAmount = withdrawAmount + amount * 0.02;
				withdrawCount++;
			}
			balance = balance - withdrawAmount;
			System.out.println(withdrawAmount + " is successfully withdrawn");
			
		}
		else{
			System.out.println("Insufficient funds");
		}
			
	}
	public double getBalance(){
		return balance;
	}
	void transaction(){
		System.out.println("Account title: " + name);
		System.out.println("Total deposit: " + depositCount);
		System.out.println("Total withdraw: " + withdrawCount);
		System.out.println("Balance: " + balance);
	}
	
}

///////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

BankAccountTest.java

import java.util.Scanner;

public class BankAccountTest{
	
	public static void main(String args[]){
		
		BankAccount account = new BankAccount();
		
		Scanner input = new Scanner(System.in);
		account.name = "Maan";
		
		int choice;
		
		do{
			System.out.println("Press 1: To Deposit an amount\nPress 2: To Withdraw an amount\nPress 3: To View the current balance\nPress 4: To Close the program");
		    choice = input.nextInt();
		
		    switch(choice){
			case 1:
			System.out.println("Enter the amount you want to Deposite");
			double depositeAmount = input.nextDouble(); 
			account.deposit(depositeAmount);
			break;
			case 2:
			System.out.println("Enter the amount you want to withdraw");
			double withdrawAmount = input.nextDouble();
			account.withdraw(withdrawAmount);
			break;
			case 3:
			System.out.println("Your current balance is " + account.getBalance());
			break;
			case 4:
			System.out.println("The program is terminated");
			account.transaction();
			break;
			default:
			System.out.println("Incorrect choice. Please try again!");
			break;
			
		
		}
		
	}while(choice!=4);
  }
	
}
public class BankAccount {
    String name;
	private double balance;
	private int depositCount = 0;
	private int withdrawCount = 0;
	
	public void deposit(double amount){
		balance += amount;
		System.out.println(amount + " is successfully Deposited");
		depositCount++;
		if(balance > 100000){
			balance = balance + (amount / 100);
		}
	}
	public void withdraw(double amount){
		if(balance >= amount){
			balance -= amount;
			System.out.println(amount + " is successfully Withdrawn");
			withdrawCount++;
		}
		else{
			System.out.println("Insufficient funds");
		}
			
	}
	public double getBalance(){
		return balance;
	}
	void transaction(){
		System.out.println("Account title: " + name);
		System.out.println("Total deposit: " + depositCount);
		System.out.println("Total withdraw: " + withdrawCount);
		System.out.println("Balance: " + balance);
	}
	
}

//////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////

import java.util.Scanner;

public class BankAccountTest{
	
	public static void main(String args[]){
		
		BankAccount account = new BankAccount();
		
		Scanner input = new Scanner(System.in);
		account.name = "Maan";
		
		int choice;
		
		do{
			System.out.println("Press 1: To Deposit an amount\nPress 2: To Withdraw an amount\nPress 3: To View the current balance\nPress 4: To Close the program");
		    choice = input.nextInt();
		
		    switch(choice){
			case 1:
			System.out.println("Enter the amount you want to Deposite");
			double depositeAmount = input.nextDouble(); 
			account.deposit(depositeAmount);
			break;
			case 2:
			System.out.println("Enter the amount you want to withdraw");
			double withdrawAmount = input.nextDouble();
			account.withdraw(withdrawAmount);
			break;
			case 3:
			System.out.println("Your current balance is " + account.getBalance());
			break;
			case 4:
			System.out.println("The program is terminated");
			account.transaction();
			break;
			default:
			System.out.println("Incorrect choice. Please try again!");
			break;
			
		
		}
		
	}while(choice!=4);
  }
	
}
BankAccount.java

public class BankAccount {
    String name;
	private double balance;
	private int depositCount = 0;
	private int withdrawCount = 0;
	
	public void deposit(double amount){
		balance += amount;
		System.out.println(amount + " is successfully Deposited");
		depositCount++;
	}
	public void withdraw(double amount){
		if(balance >= amount){
			balance -= amount;
			System.out.println(amount + " is successfully Withdrawn");
			withdrawCount++;
		}
		else{
			System.out.println("Insufficient funds");
		}
			
	}
	public double getBalance(){
		return balance;
	}
	void transaction(){
		System.out.println("Account title: " + name);
		System.out.println("Total deposit: " + depositCount);
		System.out.println("Total withdraw: " + withdrawCount);
		System.out.println("Balance: " + balance);
	}
	
}

/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////

BankAccountTest.java

import java.util.Scanner;

public class BankAccountTest{
	
	public static void main(String args[]){
		
		BankAccount account = new BankAccount();
		
		Scanner input = new Scanner(System.in);
		account.name = "Maan";
		
		int choice;
		
		do{
			System.out.println("Press 1: To Deposit an amount\nPress 2: To Withdraw an amount\nPress             3: To View the current balance\nPress 4: To Close the program");
		    choice = input.nextInt();
		
		    switch(choice){
			case 1:
			System.out.println("Enter the amount you want to Deposite");
			double depositeAmount = input.nextDouble(); 
			account.deposit(depositeAmount);
			break;
			case 2:
			System.out.println("Enter the amount you want to withdraw");
			double withdrawAmount = input.nextDouble();
			account.withdraw(withdrawAmount);
			break;
			case 3:
			System.out.println("Your current balance is " + account.getBalance());
			break;
			case 4:
			System.out.println("The program is terminated");
			account.transaction();
			break;
			default:
			System.out.println("Incorrect choice. Please try again!");
			break;
			
		
		}
		
	}while(choice!=4);
  }
	
}
// BankAccount.java

public class BankAccount {
	private String name;
	private double balance;
	
	public void deposit(double amount){
		balance += amount;
		System.out.println(amount + " is successfully Deposited");
	}
	public void withdraw(double amount){
		if(balance >= amount){
			balance -= amount;
			System.out.println(amount + " is successfully Withdrawn");
		}
		else{
			System.out.println("Insufficient funds");
		}
			
	}
	public double getBalance(){
		return balance;
	}
	
}

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

//BankAccountTest.java

import java.util.Scanner;

public class BankAccountTest{
	
	public static void main(String args[]){
		
		BankAccount account = new BankAccount();
		
		Scanner input = new Scanner(System.in);
		System.out.println("Enter account holder name: ");
		String name = input.nextLine();
		
		int choice;
		
		do{
			System.out.println("Press 1: To Deposit an amount\nPress 2: To Withdraw an amount\nPress 3: To View the current balance\nPress 4: To Close the program");
		    choice = input.nextInt();
		
		    switch(choice){
			case 1:
			System.out.println("Enter the amount you want to Deposite");
			double depositeAmount = input.nextDouble(); 
			account.deposit(depositeAmount);
			break;
			case 2:
			System.out.println("Enter the amount you want to withdraw");
			double withdrawAmount = input.nextDouble();
			account.withdraw(withdrawAmount);
			break;
			case 3:
			System.out.println("Your current balance is " + account.getBalance());
			break;
			case 4:
			System.out.println("The program is terminated");
			break;
			default:
			System.out.println("Incorrect choice. Please try again!");
			break;
			
		
		}
		
	}while(choice!=4);
  }
	
}
char[] task = new char[]{'a', 'b', 'c', 'c', 'd', 'e'};
        Map<Character, Long> map = IntStream.range(0, task.length)
                .mapToObj(idx -> task[idx]).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
/////////////////////////////////////////////////////////////////////////////////////////
//For CarApplication.java
//////////////////////////////////////////////////////////////////////////////////////////

public class CarApplication{
	public static void main(String[] args){
		
		//Create Car1 and Add values with constructor 
		Car car1 = new Car("CIVIC","2024", 7500000);
		
		//Create Car2 and Add values with constructor
		Car car2 = new Car("SWIFT","2019", 4500000);
		
		
		System.out.println("\nCar1\n");
		//Print car1 value before discount
		System.out.println("Model of Car1 = "+car1.getModel());
		System.out.println("Year of Car1 = "+car1.getYear());
		System.out.println("Price of Car1 = "+car1.getPrice()+"\n");
		
		
		car1.setDiscount(5);
		
		System.out.println("After 5% Discount");
		
		
		//Print car1 value after discount
		System.out.println("Price of Car1 = "+car1.getPrice()+"\n");
		
		
		System.out.println("Car2\n");
		
		
		//Print car1 value before discount
		System.out.println("Name of Car2 = "+car2.getModel());
		System.out.println("Year of Car2 = "+car2.getYear());
		System.out.println("Price of Car2 = "+car2.getPrice()+"\n");
		
		car2.setDiscount(7);
		
		System.out.println("After 5% Discount");
		
		//Print car1 value after discount
		System.out.println("Price of Car2 = "+car2.getPrice()+"\n");
		
		System.out.println("Numbers of Cars = "+Car.carno);
		
				
	}	
}

//////////////////////////////////////////////////////////////////////////////////////////
// FOr Car.java
//////////////////////////////////////////////////////////////////////////////////////////

public class Car{
	private String model;
	private String year;
	private double price;
	public static int carno=0;
	
	public Car(String model , String year, double price){
		setModel(model);
		setYear(year);
		setPrice(price);
		carno++;
	}
	
	public void setModel(String model){
		this.model = model;
	}
	
	public void setYear(String year){
		this.year = year;
	}
	
	public void setPrice(double price){
		if(price>0){
			this.price = price;
		}
	}
	
	public String getModel(){
		return this.model;
	}
	
	public String getYear(){
		return this.year;
	}
	
	public double getPrice(){
		return this.price;
	}
	
	public void setDis count(double discount){
		this.price =this.price - ((discount*this.price)/100);
	}
		
}

///////////////////////////////////////////////////////////////////////////////////////////
//For RectangleTest.java
///////////////////////////////////////////////////////////////////////////////////////////

public class RectangleTest{
	public static void main(String [] args){
		
		//Create rectangle1 object
		Rectangle rectangle1 = new Rectangle ();
		rectangle1.setLength(2);
		rectangle1.setWidth(4);
		
		//Print Object 1 values and method
		System.out.println("Length of Rectangle1 = "+ rectangle1.getLength());
		System.out.println("Width of Rectangle1 = "+rectangle1.getWidth());
		System.out.println("Area of Rectangle1 = "+rectangle1.getArea());
		System.out.println("Perimeter of Rectangle1 = "+rectangle1.getPerimeter());
		System.out.println();
		
		//Create rectangle2 object
		Rectangle rectangle2 = new Rectangle ();
		rectangle2.setLength(4);
		rectangle2.setWidth(6);
		
		//Print Object 2 values and method
		System.out.println("Length of Rectangle1 = "+ rectangle2.getLength());
		System.out.println("Width of Rectangle1 = "+rectangle2.getWidth());
		System.out.println("Area of Rectangle1 = "+rectangle2.getArea());
		System.out.println("Perimeter of Rectangle1 = "+rectangle2.getPerimeter());
		
		
	}
}

///////////////////////////////////////////////////////////////////////////////////////////
//For Rectangle.java
///////////////////////////////////////////////////////////////////////////////////////////


public class Rectangle{
	private double length;
	private double width;
	
	public void setLength(double length){
		this.length = length;
	}
	
	public void setWidth(double width){
		this.width = width;
	}
	
	public double getLength(){
		return length;
	}
	
	public double getWidth(){
		return width;
	}
	
	public double getArea(){
		return length * width;
	}
	
	public double getPerimeter(){
		return 2*(length + width);
	}
	
}

//For TestEmpolyee.java

public class TestEmpolyee {
    public static void main(String[] args) {
		Empolyee e1 = new Empolyee();
		Empolyee e2 = new Empolyee(3666666666666L,"mrSaadis");
		Empolyee e3 = new Empolyee(3666666666666L,"meSaadis",201000f);		
        e1.getEmpolyee();
		e2.getEmpolyee();
		e3.getEmpolyee();
		
    }
}


///////////////////////////////////////////////////////////////////////////////////////////
//For Empolyee.java
///////////////////////////////////////////////////////////////////////////////////////////


public class Empolyee {
    
	private long cnic;
	private String name;
	private double salary;
	
	public Empolyee (){
	}
	
	public Empolyee (long cnic, String name){
		setEmpolyee(cnic,name);
	}
	
	public Empolyee(long cnic, String name, double salary){
		this(cnic,name);
		this.salary = salary;
	}
	
	public void setEmpolyee (long cnic, String name){
		this.cnic = cnic;
		this.name = name;
	}
	
	public void getEmpolyee (){
		System.out.printf("Cnic no. is %d%n",this.cnic);
		System.out.printf("Name is %s%n",this.name);
		System.out.printf("Salaray is %.2f%n%n",this.salary);
	}
	
}

//For TestCircle.java

public class TestCircle {
    public static void main(String[] args) {
		
        Circle circle = new Circle(5);

        System.out.printf("Radius of the circle: %.2f%n", circle.getRadius());
        System.out.printf("Area of the circle: %.2f%n", circle.calculateArea());
        System.out.printf("Perimeter of the circle: %.2f%n%n", circle.calculatePerimeter());

        circle.setRadius(7);
        System.out.printf("Radius of the circle: %.2f%n", circle.getRadius());
        System.out.printf("Area of the circle: %.2f%n", circle.calculateArea());
        System.out.printf("Perimeter of the circle: %.2f%n%n", circle.calculatePerimeter());
		
        circle.setRadius(-3);
    }
}

///////////////////////////////////////////////////////////////////////////////////////////
//For Circle.java
///////////////////////////////////////////////////////////////////////////////////////////

public class Circle {
    private double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        if (radius > 0) {
            this.radius = radius;
        } else {
            System.out.println("Radius must be greater than 0");
        }
    }

    public double calculateArea() {
        return Math.PI * radius * radius;
    }

    public double calculatePerimeter() {
        return 2 * (Math.PI * radius);
    }
}

//Code for Banking.java

import java.util.Scanner;
public class Banking{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		BankAccount newAccount =  new BankAccount();
		
		System.out.println("Enter Account Holder's Name :");
		newAccount.name = input.nextLine();
		
		System.out.print("Enter Initial Balance : Rs ");
		newAccount.balance = input.nextInt();
		
		System.out.println("Pick the Services Services:\n1)SMS Alerts\n2)Debit Card\n3)Both\n4)None");
		int pick = input.nextInt();
		
		switch(pick){
			case 1:
				newAccount.smsAlert = true;
				newAccount.debitCard = false;
			break;
			case 2:
				newAccount.smsAlert = false;
				newAccount.debitCard = true;
			break;
			case 3:
				newAccount.smsAlert = true;
				newAccount.debitCard = true;
			break;
			case 4:
				newAccount.smsAlert = false;
				newAccount.debitCard = false;
			break;
			default:
			System.out.println("Invalid Input");
		}
		
		newAccount.accountBehaviour();
		System.out.println("After deducting annual fees, the account information is as follows:");
        newAccount.displayAccountInfo();		
	}
}


///////////////////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////////////////////


public class BankAccount{
	String name;
	double balance;
	boolean smsAlert=false;
	boolean debitCard=false;
	
	public void accountBehaviour(){
		int smsAlertFee=2000;
		int debitCardFee =5000;
		if(this.balance>=3000000){
			 System.out.println("No annual fees for PREMIUM account holders.");
                return;
		}
		 if (smsAlert) {
                this.balance -= smsAlertFee;
                System.out.println("Annual fee deducted for SMS Alerts: Rs" + smsAlertFee);
            }

        if (debitCard) {
            this.balance -= debitCardFee;
            System.out.println("Annual fee deducted for Debit Card: Rs" + debitCardFee);
        }
	}
	
	 public void displayAccountInfo() {
        System.out.println("Account Holder: " + name);
        System.out.println("Balance: Rs" + balance);
        System.out.println("SMS Alerts: " + (smsAlert ? "Subscribed" : "Not Subscribed"));
        System.out.println("Debit Card: " + (debitCard ? "Subscribed" : "Not Subscribed"));
    }	
}
import java.util.Scanner;

public class Task10{
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter total sale amount: ");
		double sale = input.nextDouble();
		
		double commission = 0;
		double bonus = 0; 
		double fixedSalary = 25000;
		
		if(sale <= 100000){
			commission = 0.02 * sale;
		}
		else if(sale > 100000 && sale < 300000){
			commission = 0.015 * sale;
			bonus = 2000;
		}
		else if(sale > 300000){
			commission = 0.01 * sale;
			bonus = 3000;
		}
		
		double totalSalary = fixedSalary + commission + bonus;
		
		System.out.printf("Total salary of employee is: %.2f",totalSalary);
		
		
	}
}
import java.util.Scanner;

public class Task9{
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter your basic salary: ");
		int basicSalary = input.nextInt();
		
		int houseRentAlowance = 0,medicalAllowance = 0;
		
		if(basicSalary < 10000){
			houseRentAlowance = (basicSalary * 50) / 100;
			medicalAllowance = (basicSalary * 10) / 100;
		}
		else if(basicSalary >= 10000 && basicSalary <= 20000){
			houseRentAlowance = (basicSalary * 60) / 100;
			medicalAllowance = (basicSalary * 15) / 100;
		}
		else if(basicSalary > 20000){
			houseRentAlowance = (basicSalary * 70) / 100;
			medicalAllowance = (basicSalary * 20) / 100;
		}
		
		int grossSalary = basicSalary + houseRentAlowance + medicalAllowance;
		
		System.out.printf("The gross salary is %d",grossSalary);
		
	}
}
import java.util.Scanner;

public class Task8{
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter end number: ");
		int endNo = input.nextInt();
		
		int count = 0;
		int i;
		String spNum = "Following are the special numbers: ";
		
		for(i = 1; i <= endNo; i++){
			if(i % 2 == 0 && i % 3 == 0 && i % 7 != 0){
				count++;
				spNum = spNum + i + ",";
			}
		}
		System.out.println("Special Number Count: "+ count);
		System.out.print(spNum);
	}
}
import java.util.Scanner;

public class Task7{
	public static void main(String args[]){
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter the age: ");
		int age = input.nextInt();
		System.out.println("Enter marks in maths: ");
		double mathMarks = input.nextDouble();
		System.out.println("Enter marks in english: ");
		double englishMarks = input.nextDouble();
		System.out.println("Enter marks in science: ");
		double scienceMarks = input.nextDouble();
		
		double totalMarks = mathMarks + englishMarks + scienceMarks;
		
		if(age > 15 && mathMarks >= 65 && englishMarks >= 55 && scienceMarks > 50 && totalMarks >= 180){
			System.out.println("Eligible for admission!");
		}
		else{
			System.out.println("Not eligible for admission");
		}
		
	}
}
import java.util.Scanner;

public class Task6{
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter first no: ");
		int num1 = input.nextInt();
		System.out.println("Enter second no: ");
		int num2 = input.nextInt();
		int reminder = num1 % num2;
		System.out.printf("The reminder is: %d\n",reminder);
		if(reminder == 0){
			System.out.printf("%d is divisible by %d",num1,num2);
		}
		else{
			System.out.printf("%d is not divisible by %d",num1,num2);
		}
		
	}
}
import java.util.Scanner;

public class Task5{
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter table #: ");
		int tableNo = input.nextInt();
		System.out.println("Enter start #: ");
		int startNo = input.nextInt();
		System.out.println("Enter end #: ");
		int endNo = input.nextInt();
		
		int i;
		for(i = startNo; i <= endNo; i++){
			System.out.printf("%d x %d = %d\n",i,tableNo,tableNo*i);
		}	
		
	}
}
import java.util.Scanner;

public class Task4{
	
	public static void main(String[] args){
		
		Scanner input = new Scanner(System.in);
		int year;
		do{
		System.out.println("Enter a year: ");
		year = input.nextInt();
		}while(year < 500);	

		if(year % 100 == 0){
			if(year % 400 == 0 && year % 4 == 0){
				System.out.println("It is a century leap year! ");
			}else{
				System.out.println("It is not a leap year! ");
			}
		}
		    else if(year % 4 == 0){
				System.out.println("It is a leap year! ");
			}
			else{
				System.out.println("It is not a leap year! ");
			}
		}	
		
	}
	
}
	
import java.util.Scanner;

public class Task3{
	
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter a four digit number: ");
		int num = input.nextInt();
		
		if(num < 1000 || num < 9999){
			System.out.println("Please enter a valid 4 digit number! ");
		}
		
		
		
		int num4 = num % 10;
		int num3 = (num % 100) / 10;
		int num2 = (num % 1000) / 100;
		int num1 = num / 1000;
		
		System.out.println("The four digits are: ");
		System.out.println(num1);
		System.out.println(num2);
		System.out.println(num3);
		System.out.println(num4);
		
		
		 
	}  
	
	
}
	
import java.util.Scanner;

public class Task1{
	
	public static void main(String args[]){
		int num;
		Scanner input = new Scanner(System.in);
		
		System.out.print("Enter a number: ");
		num = input.nextInt();
		
		
		boolean Num = true;
		for(int i = 2; i <= num; i++){
			Num = true;
			for(int j = 2; j < i; j++){
				if(i % j == 0){
					Num = false;
					break;
				}	
			}
			if(Num == true)
			System.out.println(i);
			
		}
				
			
	}
}
package com.moksha.commonactivity.common;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.ImageView;
public class ZoomableImageView extends androidx.appcompat.widget.AppCompatImageView
{
    Matrix matrix = new Matrix();

    static final int NONE = 0;
    static final int DRAG = 1;
    static final int ZOOM = 2;
    static final int CLICK = 3;
    int mode = NONE;

    PointF last = new PointF();
    PointF start = new PointF();
    float minScale = 1f;
    float maxScale = 4f;
    float[] m;

    float redundantXSpace, redundantYSpace;
    float width, height;
    float saveScale = 1f;
    float right, bottom, origWidth, origHeight, bmWidth, bmHeight;

    ScaleGestureDetector mScaleDetector;
    Context context;

    public ZoomableImageView(Context context, AttributeSet attr)
    {
        super(context, attr);
        super.setClickable(true);
        this.context = context;
        mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
        matrix.setTranslate(1f, 1f);
        m = new float[9];
        setImageMatrix(matrix);
        setScaleType(ScaleType.MATRIX);

        setOnTouchListener(new OnTouchListener()
        {

            @Override
            public boolean onTouch(View v, MotionEvent event)
            {
                mScaleDetector.onTouchEvent(event);

                matrix.getValues(m);
                float x = m[Matrix.MTRANS_X];
                float y = m[Matrix.MTRANS_Y];
                PointF curr = new PointF(event.getX(), event.getY());

                switch (event.getAction())
                {
                    //when one finger is touching
                    //set the mode to DRAG
                    case MotionEvent.ACTION_DOWN:
                        last.set(event.getX(), event.getY());
                        start.set(last);
                        mode = DRAG;
                        break;
                    //when two fingers are touching
                    //set the mode to ZOOM
                    case MotionEvent.ACTION_POINTER_DOWN:
                        last.set(event.getX(), event.getY());
                        start.set(last);
                        mode = ZOOM;
                        break;
                    //when a finger moves
                    //If mode is applicable move image
                    case MotionEvent.ACTION_MOVE:
                        //if the mode is ZOOM or
                        //if the mode is DRAG and already zoomed
                        if (mode == ZOOM || (mode == DRAG && saveScale > minScale))
                        {
                            float deltaX = curr.x - last.x;// x difference
                            float deltaY = curr.y - last.y;// y difference
                            float scaleWidth = Math.round(origWidth * saveScale);// width after applying current scale
                            float scaleHeight = Math.round(origHeight * saveScale);// height after applying current scale
                            //if scaleWidth is smaller than the views width
                            //in other words if the image width fits in the view
                            //limit left and right movement
                            if (scaleWidth < width)
                            {
                                deltaX = 0;
                                if (y + deltaY > 0)
                                    deltaY = -y;
                                else if (y + deltaY < -bottom)
                                    deltaY = -(y + bottom);
                            }
                            //if scaleHeight is smaller than the views height
                            //in other words if the image height fits in the view
                            //limit up and down movement
                            else if (scaleHeight < height)
                            {
                                deltaY = 0;
                                if (x + deltaX > 0)
                                    deltaX = -x;
                                else if (x + deltaX < -right)
                                    deltaX = -(x + right);
                            }
                            //if the image doesnt fit in the width or height
                            //limit both up and down and left and right
                            else
                            {
                                if (x + deltaX > 0)
                                    deltaX = -x;
                                else if (x + deltaX < -right)
                                    deltaX = -(x + right);

                                if (y + deltaY > 0)
                                    deltaY = -y;
                                else if (y + deltaY < -bottom)
                                    deltaY = -(y + bottom);
                            }
                            //move the image with the matrix
                            matrix.postTranslate(deltaX, deltaY);
                            //set the last touch location to the current
                            last.set(curr.x, curr.y);
                        }
                        break;
                    //first finger is lifted
                    case MotionEvent.ACTION_UP:
                        mode = NONE;
                        int xDiff = (int) Math.abs(curr.x - start.x);
                        int yDiff = (int) Math.abs(curr.y - start.y);
                        if (xDiff < CLICK && yDiff < CLICK)
                            performClick();
                        break;
                    // second finger is lifted
                    case MotionEvent.ACTION_POINTER_UP:
                        mode = NONE;
                        break;
                }
                setImageMatrix(matrix);
                invalidate();
                return true;
            }

        });
    }

    @Override
    public void setImageBitmap(Bitmap bm)
    {
        super.setImageBitmap(bm);
        bmWidth = bm.getWidth();
        bmHeight = bm.getHeight();
    }

    public void setMaxZoom(float x)
    {
        maxScale = x;
    }

    private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener
    {

        @Override
        public boolean onScaleBegin(ScaleGestureDetector detector)
        {
            mode = ZOOM;
            return true;
        }

        @Override
        public boolean onScale(ScaleGestureDetector detector)
        {
            float mScaleFactor = detector.getScaleFactor();
            float origScale = saveScale;
            saveScale *= mScaleFactor;
            if (saveScale > maxScale)
            {
                saveScale = maxScale;
                mScaleFactor = maxScale / origScale;
            }
            else if (saveScale < minScale)
            {
                saveScale = minScale;
                mScaleFactor = minScale / origScale;
            }
            right = width * saveScale - width - (2 * redundantXSpace * saveScale);
            bottom = height * saveScale - height - (2 * redundantYSpace * saveScale);
            if (origWidth * saveScale <= width || origHeight * saveScale <= height)
            {
                matrix.postScale(mScaleFactor, mScaleFactor, width / 2, height / 2);
                if (mScaleFactor < 1)
                {
                    matrix.getValues(m);
                    float x = m[Matrix.MTRANS_X];
                    float y = m[Matrix.MTRANS_Y];
                    if (mScaleFactor < 1)
                    {
                        if (Math.round(origWidth * saveScale) < width)
                        {
                            if (y < -bottom)
                                matrix.postTranslate(0, -(y + bottom));
                            else if (y > 0)
                                matrix.postTranslate(0, -y);
                        }
                        else
                        {
                            if (x < -right)
                                matrix.postTranslate(-(x + right), 0);
                            else if (x > 0)
                                matrix.postTranslate(-x, 0);
                        }
                    }
                }
            }
            else
            {
                matrix.postScale(mScaleFactor, mScaleFactor, detector.getFocusX(), detector.getFocusY());
                matrix.getValues(m);
                float x = m[Matrix.MTRANS_X];
                float y = m[Matrix.MTRANS_Y];
                if (mScaleFactor < 1) {
                    if (x < -right)
                        matrix.postTranslate(-(x + right), 0);
                    else if (x > 0)
                        matrix.postTranslate(-x, 0);
                    if (y < -bottom)
                        matrix.postTranslate(0, -(y + bottom));
                    else if (y > 0)
                        matrix.postTranslate(0, -y);
                }
            }
            return true;
        }
    }

    @Override
    protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)
    {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        width = MeasureSpec.getSize(widthMeasureSpec);
        height = MeasureSpec.getSize(heightMeasureSpec);
        //Fit to screen.
        float scale;
        float scaleX =  width / bmWidth;
        float scaleY = height / bmHeight;
        scale = Math.min(scaleX, scaleY);
        matrix.setScale(scale, scale);
        setImageMatrix(matrix);
        saveScale = 1f;

        // Center the image
        redundantYSpace = height - (scale * bmHeight) ;
        redundantXSpace = width - (scale * bmWidth);
        redundantYSpace /= 2;
        redundantXSpace /= 2;

        matrix.postTranslate(redundantXSpace, redundantYSpace);

        origWidth = width - 2 * redundantXSpace;
        origHeight = height - 2 * redundantYSpace;
        right = width * saveScale - width - (2 * redundantXSpace * saveScale);
        bottom = height * saveScale - height - (2 * redundantYSpace * saveScale);
        setImageMatrix(matrix);
    }
}
package com.jjmaurangabad;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.swiperefreshlayout.widget.CircularProgressDrawable;

import android.annotation.SuppressLint;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.jjmaurangabad.R;
import com.moksha.commonactivity.cPackage.RetrofitBuilderURL;

import java.util.Objects;

public class ImageViewActivity extends AppCompatActivity {
    String FileName="";
    ProgressBar progressBar;
ImageView iv_project;
    TextView tvImageName;
    String uri="http://192.168.1.29:8031/Video/8142bf83-f636-4ded-bf8e-d5fe50137e2d.jpg";
    float[] lastEvent = null;
    float d = 0f;
    float newRot = 0f;
    private boolean isZoomAndRotate;
    private boolean isOutSide;
    private static final int NONE = 0;
    private static final int DRAG = 1;
    private static final int ZOOM = 2;
    private int mode = NONE;
    private PointF start = new PointF();
    private PointF mid = new PointF();
    float oldDist = 1f;
    private float xCoOrdinate, yCoOrdinate;
    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image_view);
        Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
        iv_project=findViewById(R.id.iv_project);
        tvImageName=findViewById(R.id.tvImageName);
        setTitle("Image");

//        progressBar=findViewById(R.id.progressBar);
        Bundle bundle=getIntent().getExtras();
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        //Wapcos //TPI//Technical //Account

        if(bundle!=null){
            tvImageName.setText(bundle.getString("Title"));
            FileName=bundle.getString("FileName");
        }
        try {
            String url= RetrofitBuilderURL.BASE_URL +FileName;
            Glide.with(this).load(url).error(R.drawable.no_image).into(iv_project);
            CircularProgressDrawable circularProgressDrawable = new CircularProgressDrawable(this);
            circularProgressDrawable.setStrokeWidth(5f);
            circularProgressDrawable.setCenterRadius(30f);
            circularProgressDrawable.start();
            iv_project.setImageDrawable(circularProgressDrawable);
        }catch (Exception e){
            Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show();
            Log.e("ImageActivity",""+e.getMessage());
        }
        iv_project.setOnTouchListener((v, event) -> {
            ImageView view = (ImageView) v;
            view.bringToFront();
            viewTransformation(view, event);
            return true;
        });

    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                // API 5+ solution
                onBackPressed();
                return true;

            default:
                return super.onOptionsItemSelected(item);
        }
    }
    private void viewTransformation(View view, MotionEvent event) {
        switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
                xCoOrdinate = view.getX() - event.getRawX();
                yCoOrdinate = view.getY() - event.getRawY();

                start.set(event.getX(), event.getY());
                isOutSide = false;
                mode = DRAG;
                lastEvent = null;
                break;
            case MotionEvent.ACTION_POINTER_DOWN:
                oldDist = spacing(event);
                if (oldDist > 10f) {
                    midPoint(mid, event);
                    mode = ZOOM;
                }

                lastEvent = new float[4];
                lastEvent[0] = event.getX(0);
                lastEvent[1] = event.getX(1);
                lastEvent[2] = event.getY(0);
                lastEvent[3] = event.getY(1);
                d = rotation(event);
                break;
            case MotionEvent.ACTION_UP:
                isZoomAndRotate = false;
                if (mode == DRAG) {
                    float x = event.getX();
                    float y = event.getY();
                }
            case MotionEvent.ACTION_OUTSIDE:
                isOutSide = true;
                mode = NONE;
                lastEvent = null;
            case MotionEvent.ACTION_POINTER_UP:
                mode = NONE;
                lastEvent = null;
                break;
            case MotionEvent.ACTION_MOVE:
                if (!isOutSide) {
                    if (mode == DRAG) {
                        isZoomAndRotate = false;
                        view.animate().x(event.getRawX() + xCoOrdinate).y(event.getRawY() + yCoOrdinate).setDuration(0).start();
                    }
                    if (mode == ZOOM && event.getPointerCount() == 2) {
                        float newDist1 = spacing(event);
                        if (newDist1 > 10f) {
                            float scale = newDist1 / oldDist * view.getScaleX();
                            view.setScaleX(scale);
                            view.setScaleY(scale);
                        }
                        if (lastEvent != null) {
                            newRot = rotation(event);
                            view.setRotation((float) (view.getRotation() + (newRot - d)));
                        }
                    }
                }
                break;
        }
    }

    private float rotation(MotionEvent event) {
        double delta_x = (event.getX(0) - event.getX(1));
        double delta_y = (event.getY(0) - event.getY(1));
        double radians = Math.atan2(delta_y, delta_x);
        return (float) Math.toDegrees(radians);
    }

    private float spacing(MotionEvent event) {
        float x = event.getX(0) - event.getX(1);
        float y = event.getY(0) - event.getY(1);
        return (int) Math.sqrt(x * x + y * y);
    }

    private void midPoint(PointF point, MotionEvent event) {
        float x = event.getX(0) + event.getX(1);
        float y = event.getY(0) + event.getY(1);
        point.set(x / 2, y / 2);
    }
}
import java util.scanner
class oddeven
{
    public static void main(String[] args)
    {
        int n;
        System.out.print("Enter any number ");
        Scanner r=new Scannner(System.in);
        n=r.nextInt();

        if(n%2==0)
        {
            System.out.print("The number is even");
        }
        else
        {
            System.out.print("The number is odd");
        }

    }
class switch
{
public static void main(String[] args) {

  int a = 10, b = 20, ch;
  System.out.print("Enter User Choice..!\n");

  Scanner r = new Scanner(System.in);
  ch = r.nextInt();

  switch (ch) 
  {
    case 1:
      System.out.print("Sum + (a + b));
      break;
    case 2:
      System.out.print("Sub + (a - b));
      break;
    case 3:
      System.out.print("Multi + (a * b));
      break;
    case 4:
      System.out.print("Div + (a / b));
      break;
    default:
      System.out.print("Invalid Choice..");
  }
}
class Bitwise
{
   public static void main(String[] args)
   {
    int a=5,b=7;

    System.out.print("AND = " + (a & b));
    System.out.print("OR  = " + (a | b));
    System.out.print("XOR = " + (a ^ b));
    System.out.print("COMPLIMENT =  " + (~a));
   }
}
class Msg
{
    public void Show(String name)
    {
        ;;;;; // 100 line code

        synchronized(this)
        {
            for(int i = 1; i <= 3; i++)
            {
                System.out.println("how are you " + name);
            }
        }
        ;;;;; // 100 line code
    }
}

class Ourthread extends Thread
{
    Msg m;
    String name;

    Ourthread(Msg m, String name)
    {
        this.m = m;
        this.name = name;
    }

    public void run()
    {
        m.Show(name);
    }
}

class Death
{
    public static void main(String[] args)
    {
        Msg msg = new Msg(); // Create an instance of the Msg class
        Ourthread t1 = new Ourthread(msg, "om");
        Ourthread t2 = new Ourthread(msg, "harry");

        t1.start();
        t2.start();
    }
}
System.debug('Password: '+InternalPasswordGenerator.generateNewPassword('userId'));
class Table 
{
    public synchronized void printtable(int n)
    {
        for(int i=1;i<=10;i++)
        {
            System.out.println(n+"X"+i+"="+(n*i));
        }
    }
}
class Thread1 extends Thread
{
    Table t;
    Thread1(Table t)
    {
        this.t=t;
    }
    public void run()
    {
        t.printtable(5);
    }
}
class Thread2 extends Thread
{
    Table t;
    Thread2(Table t)
    {
        this.t=t;
    }
    public void run()
    {
        t.printtable(7);
    }
}

class D
{
    public static void main(String[] args)
    {
        Table r= new Table();
        
        Thread1 t1= new Thread1(r);
        Thread2 t2= new Thread2(r);
        
        t1.start();
        t2.start();
    }
}
class Bus extends Thread
{
    int available = 1;
    int passenger;

    Bus(int passenger)
    {
        this.passenger=passenger;
    }

    public synchronized void run()
    {
        String n = Thread.currentThread().getName();
        if (available >= passenger)
        {
            System.out.println(n + " seat reserved");
            available = available-passenger;
        }
        else
        {
            System.out.println("Seat not reserved");
        }
    }
}

class D
{
    public static void main(String[] args)
    {
        Bus bus = new Bus(1);

        Thread a = new Thread(bus);
        Thread s = new Thread(bus);
        Thread z = new Thread(bus);

        a.setName("raju");
        z.setName("rahul");
        s.setName("om");

        a.start();
        z.start();
        s.start();
    }
}
class S extends Thread
{
    public void run()
    {
        System.out.println(Thread.currentThread().getName());
        System.out.println(Thread.currentThread().getPriority());
    }
     
        
    
}
class F 
{
    public static void main(String[] args)
    {
        S t= new S();
        S r= new S();
        S y= new S();

        t.setName("Thread 1");
        r.setName("Thread 2");
        y.setName("Thread 3");

        t.setPriority(10);
        r.setPriority(6);
        y.setPriority(7);

        t.start();
        r.start();
        y.start();
    }
    
}
class A extends Thread
{
    public void run()
    {
        try
        {
            for(int i=1;i<=5;i++)
            {
                System.out.println("okay boss");
                Thread.sleep(1000);
            }
        }
        catch(Exception m)
        {
            System.out.println("some eror");
        }
    }
}
class F 
{
    public static void main(String[] args)
    {
        A r= new A();

        r.start();
        r.interrupt();
    }
}
class A extends Thread
{
    public void run()
    {
        System.out.println("is alive moment ");
    }
}
class F 
{
    public static void main(String[] args)
    {
        A r= new A();
        A p= new A();

        r.start();
        System.out.println(r.isAlive());
        p.start();
        System.out.println(p.isAlive());
    }
}
class A extends Thread
{
    public void run()
    {
        String n=Thread.currentThread().getName();
        
            for(int i=1;i<+5;i++)
            {
                System.out.println(n);
                
                
            }
    }
}
class P extends Thread
{
    public void run()
    {
        String n=Thread.currentThread().getName();
        
            for(int i=1;i<+5;i++)
            {
                System.out.println(n);
                
               
                
            }
    }
}

class F
{
    public static void main(String[] args)
    {
        A r = new A();
        P t = new P();

        r.setName("thread n");
        t.setName("thread m");

        r.start();
        r.stop();
        t.start();
    }
}
class A extends Thread
{
    public void run()
    {
        String n=Thread.currentThread().getName();
        
            for(int i=1;i<+5;i++)
            {
                System.out.println(n);
                
                
            }
    }
}
class P extends Thread
{
    public void run()
    {
        String n=Thread.currentThread().getName();
        
            for(int i=1;i<+5;i++)
            {
                System.out.println(n);
                Thread.yield();
               
                
            }
    }
}

class F
{
    public static void main(String[] args)
    {
        A r = new A();
        P t = new P();

        r.start();
        t.start();
    }
}
class A extends Thread
{
    public void run()
    {
        String n=Thread.currentThread().getName();
        try
        {
            for(int i=1;i<+5;i++)
            {
                System.out.println(n);
                
            }
        }
        catch(Exception a)
            {
                
            }
}
}

class F
{
    public static void main(String[] args)
    {
        A r= new A();
        A t= new A();
        A y= new A();

        r.setName("Thread 1");
        t.setName("Thread 2");
        y.setName("Thread 3");

        r.start();
        
        t.start();
        t.suspend();

        y.start();
        t.resume();
       
    }
}
class A extends Thread
{
    public void run()
    {
        String n=Thread.currentThread().getName();
        try
        {
            for(int i=1;i<+5;i++)
            {
                System.out.println(n);
                
            }
        }
        catch(Exception a)
            {
                
            }
}
}

class F
{
    public static void main(String[] args)
    {
        A r= new A();
        A t= new A();
        A y= new A();

        r.setName("Thread 1");
        t.setName("Thread 2");
        y.setName("Thread 3");

        t.start();
        try
        {
            t.join();
        }
        catch(Exception m)
        {

        }
        r.start();
        y.start();
    }
}
class A extends Thread
{
    public void run()
    {
        String n=Thread.currentThread().getName();
        try
        {
            for(int i=1;i<+5;i++)
            {
                System.out.println(n);
                Thread.sleep(2000);
            }
        }
        catch(Exception a)
            {
                
            }
}
}

class F
{
    public static void main(String[] args)
    {
        A r= new A();
        A t= new A();
        A y= new A();

        r.setName("Thread 1");
        t.setName("Thread 9");
        y.setName("Thread 10");

        r.start();
        t.start();
        y.start();
    }
}
class A extends Thread
{
    public void run()
    {
        String n= Thread.currentThread().getName();
        for(int i=1;i<=3;i++)
        {
            System.out.println(n);
        }
    }
}
class F
{
    public static void main(String[] args)
    {
        A r= new A();
        A t= new A();
        A y= new A();

        r.setName("Thread 1");
        t.setName("Thread 2");
        y.setName("Thread 3");

        r.start();
        t.start();
        y.start();
    }
}
class P implements Runnable
{
    public void run()
    {
        for(int i=1;i<=5;i++)
        {
            System.out.println("child");
        }
    }
}
class D
{
    public static void main(String[] args )
    {
        P r= new P();

        Thread t=new Thread(r);
        t.start();

        for(int i=1;i<=5;i++)
        {
            System.out.println("main");
        }
    }
}
class P extends Thread {
    @Override
    public void run() {
        try {
            for (int i = 1; i <= 5; i++) {
                System.out.println("akhil");
                Thread.sleep(1000);
            }
        } catch (InterruptedException e) {
            // Exception handling code (empty in this case)
        }
    }
}

class D {
    public static void main(String[] args) throws InterruptedException {
        P r = new P();
        r.start();  // Starts the thread

        for (int i = 1; i <= 5; i++) {
            System.out.println("tanishq");
            Thread.sleep(1000);
        }
    }
}
class P extends Thread
{
    public void run()
    {
        for(int i=1;i<=5;i++)
        {
            System.out.println("akhil");
        }
    }
}
class D
{
    public static void main(String[] args)
    {
        P r=new P();
        r.start();

        for(int i=1;i<=5;i++)
        {
            System.out.println("tanishq");
        }

    }
}
import java.io.*;
import java.util.Scanner;

class D
{
    public static void main(String[] args) throws Exception{
        try
        {
            File f= new File("C:\\Users\\HP\\Desktop\\poco");
            Scanner sc= new Scanner(f);
            while(sc.hasNextLine())
            {
                System.out.println(sc.hasNextLine());
                System.out.println(sc.nextLine());
                System.out.println(sc.hasNextLine());
            }
        }
        catch(Exception e)
        {
            System.out.println("handled");
        }
        
}
}
import java.io.*;
class D
{
    public static void main(String[] args) throws Exception
    {
        FileInputStream r= new FileInputStream("C:\\Users\\HP\\Desktop\\okay");
        FileOutputStream w= new FileOutputStream("C:\\Users\\HP\\Desktop\\boss");

        int i;
        while((i=r.read())!=-1)
        {
            w.write((char)i);
        }
        System.out.println("Data copied successfull");
    
}
}
import java.io.*;
class D
{
    public static void main(String[] args){
    File f=new File( "C:\\Users\\HP\\Desktop\\LC.txt");
    File r=new File( "C:\\Users\\HP\\Desktop\\aman");

    if(f.exists())
    {
        System.out.println(f.renameTo(r));
    }
    else
    {
        System.out.println("notfound");
    }
}
}
import java.io.*;
class D
{
    public static void main(String[] args){
    try 
    {
        FileReader f= new FileReader("C:\\Users\\HP\\Desktop\\LC.txt");
        try
        {
            int i;
            while((i=f.read())!=0)
            {
                System.out.println((char)i);
            }
        }
        finally
        {
            f.close();
        }

    }
    catch(Exception a)
    {
        System.out.println("some error");
    }
}
}
import java.io.*;
class D
{
    public static void main(String[] args)
    {
        File f = new  File("C:\\Users\\HP\\Desktop\\LC.txt");

        if(f.exists())
        {
            System.out.println(f.canRead());
            System.out.println(f.canWrite());
            System.out.println(f.length());
            System.out.println(f.getAbsolutePath());
            System.out.println(f.getName());
        }
        else
        {
            System.out.println("not found");
        }

    }

}
import java.io.*;
class D
{
    public static void main(String[] args)
    {
        try
        {
            FileWriter f= new FileWriter("C:\\Users\\HP\\Desktop\\LC.txt");
            try
            {
                f.write("hello guys ");
            }
            finally
            {
                f.close();
            }
            System.out.println("Susccesfully writen");
            

        }
        catch(Exception i)
        {
            System.out.println("aome execption found");
        }

            
    }
}
import java.io.*;
public class Main {
    public static void main(String[] args)
    {
     File f= new File("C:\\Users\\HP\\Desktop\\LC.txt");
     try
     {
        if(f.createNewFile())
     {
        System.out.println("file created");

     }
     else
     {
        System.out.println("file already created");
     } 
    }
    catch(IOException a)
    {
       System.out.println("Exception handled");
    }  
    }
    
}
class D
{
    public static void main(String[] args){
        try
        {
            m1();
        }
        catch(Exception m)
        {
            System.out.println("exception handeld ");
        }
    }
    public static void m1()
    {
        m2();
    }
    public static void m2()
    {
        System.out.println(10/0);
       
    }
}
class InvalidAgeException extends Exception
{
    InvalidAgeException(String msg)
    {
        System.out.println(msg);
    }
}
class test
{
    public static void vote(int age) throws InvalidAgeException
    {
        if(age<18)
        {
            throw new InvalidAgeException("not eligible for voting");
        }
        else
        {
            System.out.println("Eligible for voting ");
        }
    }
    public static void main(String[] args){
    
    try
    {
        vote(12);
    }
    catch(Exception d)
    {
        System.out.println(d);
    }
    }
}
class D
{
   public static void Wait() throws InterruptedException
    {
        for(int i=0;i<=10;i++)
        {
            System.out.println(i);
            Thread.sleep(1000);
            
        }
    }
    public static void main(String[] args) 
{
    try
    {
        Wait();
        System.out.println(10/0);
       
    }
    catch(Exception s)
    {
        System.out.println("some error find");
    }
}
}
class D
{
   public static void Wait() throws InterruptedException
    {
        for(int i=0;i<=10;i++)
        {
            System.out.println(i);
            Thread.sleep(1000);
            
        }
    }
    public static void main(String[] args) throws InterruptedException
    {
        Wait();
        System.out.println("some error find");
    }
}
class D
{
    void div(int a, int b) throws ArithmeticException
    {
        if (b == 0)
        {
            throw new ArithmeticException();
        }
        else
        {
            int c = a / b;
            System.out.println(c);
        }
    }

    public static void main(String[] args)
    {
        D r = new D(); // Fix the typo here
        try
        {
            r.div(10, 0);
        }
        catch (Exception e)
        {
            System.out.println("We cannot divide by 0");
        }
    }
}
class F
{
    public static void main(String[] args) throws InterruptedException
    {
        for(int i=1;i<=10;i++)
        {
            System.out.println(i);
            Thread.sleep(1000);
        }
    }
}
class D
{
    public static void main(String[] args){
        //System.out.println(10/0);
        throw new ArithmeticException("not divide it by 0");
    }
}
class D
{
    public static void main(String[] args){
        try
        {
            String a="hello";
            System.out.println(a.toUpperCase());
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
        finally
        {
            try
            {
                System.out.println(10/0);
            }
            catch(Exception p)
            {
                System.out.println(p);
            }
            finally
            {
                System.out.println("System ended");
            }
        }
    }
}
class D
{
    public static void main(String[] args){
        try
        {
            String a="hello";
            System.out.println(a.toUpperCase());
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
        finally
        {
            try
            {
                System.out.println(10/0);
            }
            catch(Exception p)
            {
                System.out.println(p);
            }
            finally
            {
                System.out.println("System ended");
            }
        }
    }
}
class G
{
    public static void main(String[] args){
    try
    {
        int a=10, b=0 , c;
        c=a/b;
        System.out.println(c);
        System.out.println("no error found");
    }
    catch(Exception a)
    {
        try
        {
            String p="okkk";
            System.out.println(p.toUpperCase());
            System.out.println("some  error found");
        }
        catch(Exception u)
        {
            System.out.println("big  error found");
        }
    }
    
    }
}
class D
{
    public static void main(String[] args){
        try{
            try{
                int a=10,b=10,c;
                c=a+b;
                System.out.println(c);
                System.out.println("no error found in ap");
            }
            catch(ArithmeticException a )
            {
                System.out.println("some error found in ap function");
            }
            int a[]={10,20,23,44};
            System.out.println(a[3]);
            System.out.println("no error found in array ");
        }
        catch(ArrayIndexOutOfBoundsException a)
        {
            System.out.println("some error found in array function");
        }
    }
}
class F
{
    public static void main(String[] args){
        try
        {
            int a=10 , b=0 , c;
            c=a+b;
            System.out.println(c);
            
            int d[]={10,20};
            System.out.println(d[1]);
            
            String j = "amkit";
            System.out.println(j.toUpperCase());
           
        }
        catch(ArrayIndexOutOfBoundsException d)
        {
            System.out.println("array error");
        }
        catch(ArithmeticException F)
        {
           System.out.println("ap error");
        }
        catch(NumberFormatException o)
        {
            System.out.println("number format error");
        }
        catch(Exception L)
        {
            System.out.println("some basic error ");
        }
    }
}
class F
{
    public static void main(String[] args){
        try
        {
            int a=10,b=0,c;
            c=a/b;
            System.out.println(c);
        }
        catch(Exception a)
        {
            
            System.out.println("error found ");
        }
        try
        {
            int a[] ={10,20,30};
            System.out.println(a[3]);
        }
        catch(ArrayIndexOutOfBoundsException b)
        {
            System.out.println("error found ");
        }
        
        
    }
}
class D
{
    public static void main(String[] args){
        
        try
        {
            int a=10,b=2,c;
            c=a/b;
            System.out.println(c);
        }
        catch(Exception a)
        {
            System.out.println("Any error found");
        }
        finally
        {
            System.out.println("no error found");
        }
        System.out.println("system ended");
    }
}
class D
{
    public static void main(String[] args){
    String str="heavy";
    
    try
    {
        int a=Integer.parseInt(str);
        System.out.println("error not found");
    }
   catch(NumberFormatException n)
   {
       System.out.println("error found");
   }
   System.out.println("system ended ");
} 
}
class D
{
    public static void main(String[] args){
        String a= null;
        
        try
        {
            System.out.print(a.toUpperCase());
            System.out.print("error not found");
            
        }
        catch(NullPointerException n )
        {
            System.out.print("error found");
        }
        
        
} 
}
class D
{
    public static void main(String[] args){
        int a=10,b=0,c;
        System.out.println("started ");
        try{
            c=a+b;
            System.out.println("sum will be "+c);
            System.out.println("no error found ");
        }
        catch(Exception e)
        {
            System.out.println("error founded");
        }
        System.out.println("ended");
    }
}
class D
{
    public static void main(String[] args ){
        System.out.println("Started ");
        int a=10,b=0,c;
        try{
            c=a/b;
        }
        catch(Exception e )
        {
            System.out.println("any errror found");
        }
        System.out.println("ended");
    }
}
class A
{
    void add(int ... a)
    {
        int sum=0;
        for(int x:a)
        {
            sum=sum+x;
        }
        System.out.println("sum of numbers will be "+sum);
    }
}
class B 
{
    public static void main(String[] args)
    {
        A r= new A();
        r.add();
        r.add(10,20);
        r.add(20,30);
        r.add(20,20);
    }
}
class A
{
    A Show()
    {
        System.out.println("first");
        return this;
    }
}
class B extends A
{
    B Show()
    {
        super.Show();
        System.out.println("second");
        return this;
    }
}
class C
{
    public static void main(String[] args)
    {
        B r = new B();
        r.Show();
    }
    
}
class A
{
    A show()
    {
        System.out.println("super");
        return this; // return as it is 
    }
}
class B extends A
{
    @Override
    B show()
    {
        System.out.println("supreme");
        return this; // return as it is
    }
}
class F
{
    public static void main(String[] args){
        B r= new B();
        r.show();
    }
}
class A
{
    void show()
    {
        System.out.print("super");
    }
}
class B extends A
{
    @Override
    void show()
    {
        System.out.print("supt");
    }
}
class F
{
    public static void main(String[] args){
        B r= new B();
        r.show();
    }
}
class D
{
    int a=10;
    D()
    {
        System.out.println(a);
    }
    public static void main(String[] args){
        
        D r = new D();
        
    }
}
class D
{
    int a=10;
    D()
    {
        System.out.println(a);
    }
    public static void main(String[] args){
        
        D r = new D();
        
    }
}
class D
{
    int a=10;
    public static void main(String[] args){
        
        D r = new D();
        System.out.println(r.a);
    }
}
final class D
{
    void number()
    {
        System.out.println("true");
    }
    
}
class P extends D // it will show error as its ssinged as final ....
{
   
    void number()
    {
        System.out.println("true");
    }
    
}

class O
{
    public static void main(String[] args)
    {
        P r = new P();
        r.number();
        
}
}
class Final 
{
    public static void main(String[] args)
    {
        final int a=20;// fial value now it cannot be changed 
        System.out.print(a);
        
        a=20;// cannot assinged once again
        System.out.print(a);
    }
}
interface D
{
    default void call()
    {
        plus(10,20);
    }
    private void plus(int x,int y)
    {
        System.out.println("plus answer will be "+(x+y));
    }
}
class X implements D
{
    public void subtract(int x, int y)
    {
        System.out.println("subtract answer will be "+(x-y));
    }
}
class C
{
    public static void main(String[] args)
    {
        X r= new X();
        r.call();
        r.subtract(20,10);
    }
}
interface A
{
    public static void Show()
    {
        System.out.println("okay bhai");
    }
}
class  D
{
    public static void main(String[] args)
    {
        A.Show();
    }
}
interface A
{
    void S();
    void P();
    default void L()
    {
        System.out.println("hii baby");
    }
}
class D implements A
{
    public void S()
    {
        System.out.println("class D");
    }
    public void P()
    {
        System.out.println("class P");
    }
}
class p
{
    public static void main(String[] args)
    {
        D r= new D();
        r.S();
        r.P();
        r.L();
    }
}
import java.util.LinkedList;
import java.util.Queue;

public class Main { 
  public static void main(String[] args) {
    Queue songs = new LinkedList<>();
    songs.add("Szmaragdy i Diamenty");
    songs.add("Ja uwielbiam ją");
    songs.add("Chłop z Mazur");

    System.out.println("Playlista na dziś: " + songs);
    for (int i = 0; i < songs.size(); i++) {
        System.out.println("gram: " + songs.poll() +
              " [następnie: " + songs.peek() + "]");
    }
}
} 
interface W {
    void sum();
}

interface S extends W {
    void sub();
}

class K implements S {
    @Override
    public void sum() {
        int a = 10, b = 20, sum;
        sum = a + b;
        System.out.println(sum);
    }

    @Override
    public void sub() {
        int a = 20, b = 10, sub;
        sub = a - b; // Fix: Corrected the subtraction operation
        System.out.println(sub);
    }
}

class D {
    public static void main(String[] args) {
        K r = new K();
        r.sum();
        r.sub(); // Fix: Corrected the method call
    }
}
interface A {
    void show();
}

interface S {
    void hide();
}

class W implements A, S {
    public void show() {
        System.out.println("ok boss");
    }

    public void hide() {
        System.out.println("no boss");
    }
}

class L {
    public static void main(String[] args) {
        W r = new W();
        r.show();
        r.hide();
    }
}
interface X
{
    void frontened();
    void backened();
}
abstract class D implements X
{
    @Override
    public void frontened()
    {
        System.out.println("BY JAVA");
    }
}
class W extends D
{
    @Override
    public void backened()
    {
        System.out.println("BY HTml and css ");
    }
}
class V
{
    public static void main(String[] args)
    {
        W r= new W();
        r.frontened();
        r.backened();
    }
    
}
interface customer
{
    int a=20;
    void purchase();
}
class Owner implements customer
{
    @Override
    public void purchase()
    {
        System.out.println("customer bought "+a + "kg");
    }
    
    
}
class A
{
    public static void main(String[] args)
    {
        
        System.out.println(customer.a+"kg");/* it can be call without making an obj that is why its static*/
    }
}
interface customer
{
    int a= 20; /* that is why its final because one value  is assinged it becomes final*/
    
    void purchase();
}
class Raju implements customer
{
    @Override
    public void purchase()
    {
        System.out.println("raj needs "+a+"kg");
    }
}
class Check
{
    public static void main(String[] args)
    {
        customer r= new Raju();
        r.purchase();
    }
}
import java.util.Scanner;
interface client
{
    void input();
    void output();
}
class raju implements client
{
    String name ; double salary;
    public void input()
    {
        Scanner r = new Scanner(System.in);
        System.out.println("eNTER YOUR NAME");
        name = r.nextLine();
        
        System.out.println("eNTER YOUR sal");
        salary = r.nextDouble();
    }
    public void output()
    {
    System.out.println(name +" "+salary);
    
    }
    public static void main(String[] args){
        client c = new raju();
        c.input();
        c.output();
    }
abstract class A
{
    public abstract void MAIN();
    
}
abstract class AKHIL extends A
{
    @Override
    public void MAIN()
    {
        System.out.println("topper");
    }
    
}
class TANISHQ extends AKHIL
{
    @Override
    public void MAIN()
    {
        System.out.println("loser");
    }
}
class D
{
    public static void main(String[] args)
    {
        TANISHQ r =new TANISHQ();
      
        
        r.MAIN();
        
    }
}
abstract class D {
    public abstract void Developer();
}

class Java extends D {
    @Override
    public void Developer() {
        System.out.println("James");
    }
}

class Html extends D {
    @Override
    public void Developer() {
        System.out.println("Tim");
    }
}

public class S {
    public static void main(String[] args) {
        Java r = new Java();
        Html k = new Html();
        r.Developer();
        k.Developer();
    }
}
abstract class animal
{
    public abstract void sound();
}
class dog extends animal
{
    public void sound()
    {
    System.out.println("dog is barking");
    }
}
class tiger extends animal
{
    public void sound()
    {
    System.out.println("dog is tiger");
        
    }
    
}
class S{
    public static void main(String[] args){
        dog r= new dog();
        tiger k= new tiger();
        
        r.sound();
        k.sound();
    }
}
abstract class A
{
    void MAIN()
    {
    System.out.println("ooo");
    }
}
class S extends A
{
    
}
class P
{
    public static void main(String[] args){
        S r= new S();
        r.MAIN();
    }
}
class A
{
    private int value;
    
    public void setValue(int x)
    {
        value=x;
    }
    public int getValue()
    {
        return value;
    }
}
class D
{
    public static void main(String[] args){
    A r= new A();
    r.setValue(500);
    System.out.println(r.getValue());
    }
}
class shape 
{
    void draw()
    {
        System.out.println("can't say about shape");
    }
}
class square extends shape
{
    @Override
    void draw()
    {
        super.draw();
        System.out.println("shape is square");
    }
}
class B
{
    public static void main(String[] args)
    {
        shape r=new square();
        r.draw();
    }
}
class A
{  
    void C()
    {
        int a=20; int b=30; int c;
        c=a+b;
        System.out.println(c);
    }
    void C(int x,int y)
    {
        int c;
        c=x+y;
        System.out.println(c);
    }
    void C(int x,double y)
    {
        double c;
        c=x+y;
        System.out.println(c);
    }
    public static void main(String[] args)
    {
        A r= new A();
        r.C();
        r.C(10,20);
        r.C(11,22.33);
    }

}
class A
{
    void SHOW()
    {
        System.out.println(this);
    }
    public static void main(String[] args)
    {
        A r = new A();
        System.out.println(r);
        r.SHOW();
    }

}
class A
{
    
        int a=20;
        
}
class B extends A
{
    int a=10;
    void S()
    {
        System.out.println(super.a);
        System.out.println(a);
    }
}
class C
{
    public static void main(String[] args)
{
    B r= new B();
    r.S();
}
}
class A
{
    void S()
    {
        System.out.println("srk");
    }
}
class B
{
    void S()
    {
        super.show();
        System.out.println("srk");
    }
}
class C
{
    public staic void main (String[] args)

{
    B r= new B();
    r.S();
}

}
class A
{
    
    void ADD()
    {
        
        System.out.println("enter your name ");
    }
}
class B extends A
{
void SUB()
    {
        
        System.out.println("Enter your enrollemnet number");
    }
}
class C extends A
 
{
    void MULTI()
    {
        
        System.out.println("enter your college name ");
    }
}
    
class D
{
    public static void main(String[] args)
    {
       B r = new B();
       C r2= new C();
       
       r.ADD(); r.SUB();
       r2.ADD(); r2.MULTI();
    }
}
class A
{
    int a; int b; int c;
    void ADD()
    {
        a=1;
        b=2;
        c=a+b;
        System.out.println("addition of number "+c );
    }
    void SUB()
    {
        a=1;
        b=2;
        c=a-b;
        System.out.println("subtraction of number "+c );
    }
}
class B extends A
{
    void MULTI()
    {
        a=1;
        b=2;
        c=a*b;
        System.out.println("multiplication of number "+c );
    }
}
class C extends B
{
        void REMAINDER()
    {
        a=1;
        b=2;
        c=a%b;
        System.out.println("remainder of number "+c );
    }
}
class D{
    public static void main(String[] args)
    {
        C r = new C();
        r.ADD();
        r.SUB();
        r.MULTI();
        r.REMAINDER();
    }
}
class A
{
    int a; String b;
    void input()
    {
        System.out.println("enter your roll no and name ");
    }
    
      
    
    
}
class B extends A
{
    void D()
    {
        a=10; b="om";
        System.out.println(a+" "+b);
    }
    public static void main(String[] args){
    B r=new B();
    r.input(); 
    r.D(); 
    }
    
}
class A
{
    int a=10; static int  b=20;
    
    {
        System.out.println(a+" "+b);
    }
    static{
        System.out.println(b);
    }
    
    
    public static void main(String[] args){
        A r = new A();
    }
    
    
}
class A
{
    static{
        System.out.println("learn ");
    }
    {
        System.out.println("learn coding");
    }
    
    
    public static void main(String[] args){
        A r = new A();
    }
    
    
}
class A
{
    static {
        System.out.print("jojo");
    }
    
       public static void main(String[] args) {
    }
    
}
class S
{
    int a,b;
    S()
    {
        a=20 ; b=30;
        System.out.println(a+" "+b);
    }
    
    {/*static*/
        a=10 ; b=10;
        System.out.println(a+" "+b);
    }
}
class A
{
    public static void main(String[] args)
    {
        
        S r = new S();
        
    
    }
}
class A 
{
    int a; double b; String c;
    A()
    {
        a= 10; b= 0.098; c= "hii";
        
    }
    A(int x)
    {
        a=x;
    }
    A( double y, String z)
    {
        b=y; c=z;
    }
    
}
class Z
{
   public static void main(String[] args)
   {
      A r = new A();
      A r2= new A(10);
      A r3= new A(0.99," ok");
      System.out.println(r.a+" "+r.b+" "+r.c);
      System.out.println(r2.a);
      System.out.println(r3.b+" "+r3.c);
   }


}
class A 
{
    int a; String b;
    private A()
    {
        a= 10;
        b= "OK";
        System.out.print(a+" "+b);
    }
    public static void main(String[] args){
    A r = new A();
    }
}
// Copy constructor
class A
{
    int a; String b;
    
    
    A()   
    {
        a=10; b=" only";
        System.out.println(a+b);
    }
    
    A(A ref)
    {
        a=ref.a;
        b=ref.b;
        System.out.println(a+b);
    }
}
class B 
{
    public static void main(String[] args )
    {
        A r= new A();
        A r2= new A(r);
    }
}
import java.util.Scanner;

class A

{
    int x, y;
    A(int a, int b)
    {
        x=a; y=b;
        
    }
    void ok()
    {
        System.out.print(x+" "+y);
    }
    
}

class B
{
    public static void main(String[] args)
    {
        A r = new A(100,200);
        r.ok();
    }
}
import java.util.Scanner;

class A

{
    int a; String b; boolean c;
    /*A()
    {
        a=10;b="OK";c=true;
        
    }*/
    void ok()
    {
        System.out.print(a+" "+b+" "+c+" ");
    }
    
}

class B
{
    public static void main(String[] args)
    {
        A r = new A();
        r.ok();
    }
}
import java.util.Scanner; 
class HelloWorld {
    public static void main(String[] args) {
        
        int a[]=new int[5];
        Scanner r = new Scanner(System.in);
        System.out.print("Enter elements of arrays");
        
        for(int i=0;i<a.length;i++)
        {
            a[i]=r.nextInt();
        }
        System.out.println (" arrays");
        for(int i=0;i<a.length;i++)
        {
            System.out.print(a[i]+" ");
        }
        System.out.println ("reverse  arrays");
        for(int i=a.length-1;i>=0;i--)
        {
             System.out.print(a[i]+" ");
        }
    }
}
import java.util.Arrays; 
class HelloWorld {
    public static void main(String[] args) {
        
        String a[]={"learn","coding","Keypoints"};
        System.out.println(Arrays.toString(a));
        System.out.println(Arrays.asList(a));
        
        int b[][]={{10,20},{30,40}};
        System.out.println(Arrays.deepToString(b));
        
    }
}
import java.util.Scanner;
class HelloWorld {
    public static void main(String[] args) {
        
        int n,r;
        Scanner ref = new Scanner(System.in);
        System.out.println("enter you value !");
        n=ref.nextInt();
        
        while(n>0)
        {
            r=n%10;
            System.out.print(r);
            n=n/10;
        }
        
    }
import java.util.Scanner;
class HelloWorld {
    public static void main(String[] args) {
        int month ;
        Scanner r=new Scanner(System.in);
        System.out.println("input month");
        month=r.nextInt();
        
        switch(month)
        {
            case 1:System.out.print("january and days 31");
            break;
            case 2:System.out.print("febuary and days 28");
            break;
            case 3:System.out.println("march and days 31");
            break;
            case 4:System.out.println("april and days 30");
            break;
            case 5:System.out.println("may and days 31");
            break;
            case 6:System.out.println("june and days 30");
            break;
            case 7:System.out.println("july and days 31");
            break;
            case 8:System.out.println("august and days 31");
            break;
            case 9:System.out.println("september and days 30");
            break;
            case 10:System.out.println("october and days 31");
            break;
            case 11:System.out.println("november and days 30");
            break;
            case 12:System.out.println("december and days 31");
            break;
            
            
        }
        
        
        
    }
    
    
}
import java.util.Scanner;
class HelloWorld {
    public static void main(String[] args) {
        int a;
        Scanner r=new Scanner(System.in);
        System.out.println("input a value");
        a=r.nextInt();
        
        for(int i=1;i<=a;i++)
        {
            if(a%i==0)
            {
                System.out.println(i+" "); 
                
            }
        }
        
    }
    
    
}
import java.util.ArrayList;
import java.util.Scanner;

public class StudentInformationSystem {

    private static ArrayList<Student> students = new ArrayList<>();
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        while (true) {
            displayMenu();
            int choice = scanner.nextInt();
            scanner.nextLine(); // Consume the newline character

            switch (choice) {
                case 1:
                    addStudent();
                    break;
                case 2:
                    viewStudentList();
                    break;
                case 3:
                    searchStudent();
                    break;
                case 4:
                    System.out.println("Exiting program. Goodbye!");
                    System.exit(0);
                default:
                    System.out.println("Invalid choice. Please try again.");
            }
        }
    }

    private static void displayMenu() {
        System.out.println("Student Information System Menu:");
        System.out.println("1. Add Student");
        System.out.println("2. View Student List");
        System.out.println("3. Search for Student");
        System.out.println("4. Exit");
        System.out.print("Enter your choice: ");
    }

    private static void addStudent() {
        System.out.print("Enter student ID: ");
        int id = scanner.nextInt();
        scanner.nextLine(); // Consume the newline character

        System.out.print("Enter student name: ");
        String name = scanner.nextLine();

        students.add(new Student(id, name));
        System.out.println("Student added successfully!");
    }

    private static void viewStudentList() {
        if (students.isEmpty()) {
            System.out.println("No students in the system yet.");
        } else {
            System.out.println("Student List:");
            for (Student student : students) {
                System.out.println("ID: " + student.getId() + ", Name: " + student.getName());
            }
        }
    }

    private static void searchStudent() {
        System.out.print("Enter student ID to search: ");
        int searchId = scanner.nextInt();
        scanner.nextLine(); // Consume the newline character

        boolean found = false;
        for (Student student : students) {
            if (student.getId() == searchId) {
                System.out.println("Student found: ID: " + student.getId() + ", Name: " + student.getName());
                found = true;
                break;
            }
        }

        if (!found) {
            System.out.println("Student with ID " + searchId + " not found.");
        }
    }

    private static class Student {
        private int id;
        private String name;

        public Student(int id, String name) {
            this.id = id;
            this.name = name;
        }

        public int getId() {
            return id;
        }

        public String getName() {
            return name;
        }
    }
}
import java.util.ArrayList;
import java.util.Scanner;

public class StudentInformationSystem {

    private static ArrayList<Student> students = new ArrayList<>();
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        while (true) {
            displayMenu();
            int choice = scanner.nextInt();
            scanner.nextLine(); // Consume the newline character

            switch (choice) {
                case 1:
                    addStudent();
                    break;
                case 2:
                    viewStudentList();
                    break;
                case 3:
                    searchStudent();
                    break;
                case 4:
                    System.out.println("Exiting program. Goodbye!");
                    System.exit(0);
                default:
                    System.out.println("Invalid choice. Please try again.");
            }
        }
    }

    private static void displayMenu() {
        System.out.println("Student Information System Menu:");
        System.out.println("1. Add Student");
        System.out.println("2. View Student List");
        System.out.println("3. Search for Student");
        System.out.println("4. Exit");
        System.out.print("Enter your choice: ");
    }

    private static void addStudent() {
        System.out.print("Enter student ID: ");
        int id = scanner.nextInt();
        scanner.nextLine(); // Consume the newline character

        System.out.print("Enter student name: ");
        String name = scanner.nextLine();

        students.add(new Student(id, name));
        System.out.println("Student added successfully!");
    }

    private static void viewStudentList() {
        if (students.isEmpty()) {
            System.out.println("No students in the system yet.");
        } else {
            System.out.println("Student List:");
            for (Student student : students) {
                System.out.println("ID: " + student.getId() + ", Name: " + student.getName());
            }
        }
    }

    private static void searchStudent() {
        System.out.print("Enter student ID to search: ");
        int searchId = scanner.nextInt();
        scanner.nextLine(); // Consume the newline character

        boolean found = false;
        for (Student student : students) {
            if (student.getId() == searchId) {
                System.out.println("Student found: ID: " + student.getId() + ", Name: " + student.getName());
                found = true;
                break;
            }
        }

        if (!found) {
            System.out.println("Student with ID " + searchId + " not found.");
        }
    }

    private static class Student {
        private int id;
        private String name;

        public Student(int id, String name) {
            this.id = id;
            this.name = name;
        }

        public int getId() {
            return id;
        }

        public String getName() {
            return name;
        }
    }
}
#include <stdio.h>
#include <stdlib.h>
 
/* A binary tree node has data, pointer to left child
   and a pointer to right child */
struct node {
    char data;
    struct node* left;
    struct node* right;
};
 
/* Prototypes for utility functions */
int search(char arr[], int strt, int end, char value);
struct node* newNode(char data);
 
/* Recursive function to construct binary of size len from
   Inorder traversal in[] and Preorder traversal pre[].  Initial values
   of inStrt and inEnd should be 0 and len -1.  The function doesn't
   do any error checking for cases where inorder and preorder
   do not form a tree */
struct node* buildTree(char in[], char pre[], int inStrt, int inEnd)
{
    static int preIndex = 0;
 
    if (inStrt > inEnd)
        return NULL;
 
    /* Pick current node from Preorder traversal using preIndex
    and increment preIndex */
    struct node* tNode = newNode(pre[preIndex++]);
 
    /* If this node has no children then return */
    if (inStrt == inEnd)
        return tNode;
 
    /* Else find the index of this node in Inorder traversal */
    int inIndex = search(in, inStrt, inEnd, tNode->data);
 
    /* Using index in Inorder traversal, construct left and
     right subtress */
    tNode->left = buildTree(in, pre, inStrt, inIndex - 1);
    tNode->right = buildTree(in, pre, inIndex + 1, inEnd);
 
    return tNode;
}
 
/* UTILITY FUNCTIONS */
/* Function to find index of value in arr[start...end]
   The function assumes that value is present in in[] */
int search(char arr[], int strt, int end, char value)
{
    int i;
    for (i = strt; i <= end; i++) {
        if (arr[i] == value)
            return i;
    }
}
 
/* Helper function that allocates a new node with the
   given data and NULL left and right pointers. */
struct node* newNode(char data)
{
    struct node* node = (struct node*)malloc(sizeof(struct node));
    node->data = data;
    node->left = NULL;
    node->right = NULL;
 
    return (node);
}
 
/* This function is here just to test buildTree() */
void printInorder(struct node* node)
{
    if (node == NULL)
        return;
 
    /* first recur on left child */
    printInorder(node->left);
 
    /* then print the data of node */
    printf("%c ", node->data);
 
    /* now recur on right child */
    printInorder(node->right);
}
 
/* Driver program to test above functions */
int main()
{
    char in[] = { 'D', 'G', 'B', 'A', 'H', 'E', 'I', 'C', 'F' };
    char pre[] = { 'A', 'B', 'D', 'G', 'C', 'E', 'H', 'I', 'F' };
    int len = sizeof(in) / sizeof(in[0]);
    struct node* root = buildTree(in, pre, 0, len - 1);
 
    /* Let us test the built tree by printing Inorder traversal */
    printf("Inorder traversal of the constructed tree is \n");
    printInorder(root);
    getchar();
}
//OUTPUT:

Inorder traversal of the constructed tree is 
D G B A H E I C F 
#include <stdio.h>
#include <stdlib.h>

typedef struct Node 
{
    char data;
    struct Node* left;
    struct Node* right;
} Node;

Node* createNode(char value)
{
    Node* newNode = (Node*)malloc(sizeof(Node*));
    newNode -> data = value;
    newNode -> left = NULL;
    newNode -> right = NULL;
    
    return newNode;
}

void preOrder(Node* root)
{
    if(root != NULL) {
        printf("%c ", root -> data);
        preOrder(root -> left);
        preOrder(root -> right);
    }
}

void inOrder(Node* root)
{
    if(root != NULL) {
        inOrder(root -> left);
        printf("%c ", root -> data);
        inOrder(root -> right);
    }
}

void postOrder(Node* root)
{
    if(root != NULL) {
        postOrder(root -> left);
        postOrder(root -> right);
        printf("%c ", root -> data);
    }
}
int main() {
   
   Node* root = createNode('A');
   root ->left = createNode('B');
   root -> right = createNode('C');
   root -> left -> left = createNode('D');
   root -> left -> right = createNode('E');
   root -> right -> left = createNode('F');
   root -> right -> right = createNode('G');
   
   printf("Pre-Order Traversal: ");
   printf("\n");
   preOrder(root);
   
   printf("\n\nIn-Order Traversal: ");
   printf("\n");
   inOrder(root);
   
   printf("\n\nPost-Order Traversal: ");
   printf("\n");
   postOrder(root);

    return 0;
}

//OUTPUT:

Pre-Order Traversal: 
A B D E C F G 

In-Order Traversal: 
D B E A F C G 

Post-Order Traversal: 
D E B F G C A 
Question: 
Write a C program to create a binary tree as shown in bellow, with the following elements: 50, 17, 72, 12, 23, 54, 76, 9, 14, 25 and 67. After creating the tree, perform an in-order traversal to display the elements. 

Answer:

#include <stdio.h>
#include <stdlib.h>

struct Node 
{
    int data;
    struct Node* left;
    struct Node* right;
};

struct Node* createNode(int value)
{
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode -> data = value;
    newNode -> left = NULL;
    newNode -> right = NULL;
    
    return newNode;
}
void inOrderTraversal(struct Node* root)
{
    if(root!=NULL) {
        inOrderTraversal(root -> left);
        printf("%d ", root -> data);
        inOrderTraversal(root -> right);
    }
}

int main() {
   struct Node* root = createNode(50);
   root -> left = createNode(17);
   root -> right = createNode(72);
   
   root -> left -> left = createNode(12);
   root -> left -> right = createNode(23);
   
   root -> left -> left -> left = createNode(9);
   root -> left -> left -> right = createNode(14);
   
   root -> left -> right -> right = createNode(25);
   
   root -> right -> left = createNode(54);
   root -> right -> right = createNode(76);
   root -> right -> left -> right = createNode(67);
   inOrderTraversal(root);

    return 0;
}

//OUTPUT:

In-Order Traversal: 
9 12 14 17 23 25 50 54 67 72 76 
import java.net.*;
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        try {
            // Step 1: Open a connection to the URL and create a BufferedReader to read from it
            URL url = new URL("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt");
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));

            // Step 2: Group words by sorted characters (anagrams)
            Map<String, List<String>> anagrams = reader.lines()
                    .collect(Collectors.groupingBy(Main::sortedString));

            // Step 3: Find the maximum number of anagrams in a single group
            int maxAnagrams = anagrams.values().stream()
                    .mapToInt(List::size)
                    .max()
                    .orElse(0);
          
			// Step 4: Print the group(s) with the maximum number of anagrams, sorted lexicographically

		// Stream through the values of the 'anagrams' map, which represent groups of anagrams
anagrams.values().stream()
        // Filter to include only groups with the maximum number of anagrams
        .filter(group -> group.size() == maxAnagrams)
        
        // For each qualifying group, sort its elements lexicographically
        .peek(Collections::sort)
        
        // Sort the groups based on the lexicographically first element of each group
        .sorted(Comparator.comparing(list -> list.get(0)))
        
        // For each sorted group, print it as a space-separated string
        .forEach(group -> System.out.println(String.join(" ", group)));
          
          
                // Step 5: Close the BufferedReader
            reader.close();
        } catch (IOException e) {
            // Handle IOException if it occurs
            e.printStackTrace();
        }
    }

private static String sortedString(String word) {
    // Step 1: Convert the word to a character array
    char[] letters = word.toCharArray();
    
    // Step 2: Sort the characters in lexicographic order
    Arrays.sort(letters);
    
    // Step 3: Create a new string from the sorted character array
    return new String(letters);
}
# include <stdio.h>
# define MAX 6
int CQ[MAX];
int front = 0;
int rear = 0;
int count = 0;
void insertCQ(){
int data;
if(count == MAX) {
printf("\n Circular Queue is Full");
}
else {
printf("\n Enter data: ");
scanf("%d", &data);
CQ[rear] = data;
rear = (rear + 1) % MAX;
count ++;
printf("\n Data Inserted in the Circular Queue ");
    }
}
void deleteCQ()
{
    if(count == 0) {
        printf("\n\nCircular Queue is Empty..");
        
    }
        else {
            printf("\n Deleted element from Circular Queue is %d ", CQ[front]);
            front = (front + 1) % MAX;
            count --; 
        }
}
void displayCQ()
{
    int i, j;
    if(count == 0) {
        printf("\n\n\t Circular Queue is Empty "); }
        else {
            printf("\n Elements in Circular Queue are: ");
            j = count;
            for(i = front; j != 0; j--) {
                printf("%d\t", CQ[i]);
                i = (i + 1) % MAX; 
            }
        } 
}
int menu() {
    int ch;
    printf("\n \t Circular Queue Operations using ARRAY..");
    printf("\n -----------**********-------------\n");
    printf("\n 1. Insert ");
    printf("\n 2. Delete ");
    printf("\n 3. Display");
    printf("\n 4. Quit ");
    printf("\n Enter Your Choice: ");
    scanf("%d", &ch);
    return ch;
    
}
void main(){
    int ch;
    do {
        ch = menu();
        switch(ch) {
            case 1: insertCQ(); break;
            case 2: deleteCQ(); break;
            case 3: displayCQ(); break;
            case 4:
            return;
            default:
            printf("\n Invalid Choice ");
            
        }
        } while(1);
}
#include <stdio.h>
#include <stdlib.h>
#define SIZE 5

int front = -1;
int rear = -1;
int Q[SIZE];

void enqueue();
void dequeue();
void show();

int main ()
{
    int choice;
    while (1)
    {
        printf("\nEnter 1 for enqueue\n");
        printf("Enter 2 for dequeue\n");
        printf("Enter 3 to see the Queue Elements\n");
        printf("Enter 4 to Quit\n");
        printf("\nEnter Your Choice: ");
        scanf("%d", &choice); 

        switch (choice)
        {
        case 1:
            enqueue();
            break; 
        case 2:
            dequeue();
            break;
        case 3:
            show();
            break;
        case 4:
            exit(0);
        default:
            printf("\nWrong choice\n");
        }
    }

    return 0;
}

void enqueue()
{
    int val;
    if (rear == SIZE - 1)
        printf("\nQueue is Full.");
    else
    {
        if (front == -1)
            front = 0;
        printf("\nInsert the value: ");
        scanf("%d", &val); 
        rear = rear + 1;
        Q[rear] = val;
    }
}

void dequeue()
{
    if (front == -1 || front > rear)
        printf("\nQueue Is Empty.");
    else
    {
        printf("\nDeleted Element is %d", Q[front]);
        front = front + 1;
    }
}
void show()
{
    if (front == rear == -1 || front > rear)
    {
        printf("\nQueue is Empty.");
    }
    else
    {
        for (int i = front; i <= rear; i++) 
            printf("%d\t", Q[i]);
    }
}
#include <stdio.h>
#define MAX 6
int Q[MAX];
int front, rear;
void insertQ()
{
    int data;
    if(rear==MAX) {
        printf("\nLinear Queue is Full: we cannot add an element.");
    }
    else{
        printf("Enter Data: ");
        scanf("\n%d", & data );
        Q[rear] = data;
        rear++;
    }
}
void deleteQ()
{
    if(rear==front){
        printf("Queue is Empty. we cannot delete an element.");
    }
    else {
        printf("\nDeleted Element is %d ", Q[front]);
        front++;
    }
}

void displayQ()
{
    int i;
    if(front==rear) {
        printf("\nQueue is Empty. we dont Have any element yet!");
    }
    else {
        printf("\nElements in the Queue is : ");
        for(int i = front; i<rear; i++){
            printf("%d ", Q[i]);
        }
    }
}

int menu()
{
    int choice;
    //clrscr();
    printf("\nQueus Operation using Array: ");
    printf("\n 1. insert Element.");
    printf("\n 2. Delete Element.");
    printf("\n 3. Display Elements.");
    printf("\n 4. Quit.");
    
    printf("\n\nEnter Your Choice: ");
    scanf("%d", & choice);
    return choice;
}

int main() {
   int choice;
   do
   {
       choice = menu();
       switch(choice) 
       {
           case 1: insertQ(); break;
           case 2: deleteQ(); break;
           case 3: displayQ(); break;
       }
       //getchoice();
   }
   while(1);

    //return 0;
}

//OUTPUT:
Queus Operation using Array: 
1. insert Element.
2. Delete Element.
3. Display Elements.
4. Quit.

Enter Your Choice: 1
Enter Data: 50
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 1
Enter Data: 60
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 1
Enter Data: 70
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 3
Elements in the Queue is : 50 60 70 
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 1
Enter Data: 80
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 3
Elements in the Queue is : 50 60 70 80 
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 2
Deleted Element is 50 
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 3
Elements in the Queue is : 60 70 80 
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 1
Enter Data: 20
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 1
Enter Data: 30
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 1
Linear Queue is Full: we cannot add an element.
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 3
Elements in the Queue is : 60 70 80 20 30 
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 1
Linear Queue is Full: we cannot add an element.
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 3
Elements in the Queue is : 60 70 80 20 30 
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 2
Deleted Element is 60 
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 3
Elements in the Queue is : 70 80 20 30 
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 1
Linear Queue is Full: we cannot add an element.
Queus Operation using Array: 
 1. insert Element.
 2. Delete Element.
 3. Display Elements.
 4. Quit.

Enter Your Choice: 
/*
 * Une collection TreeMap est par défaut triée avec ses clés, mais si vous avez besoin de trier une TreeMap
 * par valeurs, Java fournit un moyen en utilisant la classe Comparator.
 */

package TreeMap;

import java.util.*;

/**
 *
 * @author fabrice
 */
class Tri_par_valeurs {
  
  // Static method which return type is Map and which extends Comparable. 
  // Comparable is a comparator class which compares values associated with two keys.  
  public static <K, V extends Comparable<V>> Map<K, V> valueSort(final Map<K, V> map) {
      
      // compare the values of two keys and return the result
      Comparator<K> valueComparator = (K k1, K k2) -> {
          int comparisonResult = map.get(k1).compareTo(map.get(k2));
          if (comparisonResult == 0) return 1;
          else return comparisonResult;
      };
      
      // Sorted Map created using the comparator
      Map<K, V> sorted = new TreeMap<K, V>(valueComparator); // create a new empty TreeMap ordered according to the given comparator
      
      sorted.putAll(map); // copy mappîngs of "map" into "sorted" an order them by value
      
      return sorted;
  }
  
    public static void main(String[] args) {
        TreeMap<Integer, String> map = new TreeMap<Integer, String>();
        
        // Feed the Map
        map.put(1, "Anshu"); 
        map.put(5, "Rajiv"); 
        map.put(3, "Chhotu"); 
        map.put(2, "Golu"); 
        map.put(4, "Sita"); 
        
        // Display elements before sorting 
        Set unsortedSet = map.entrySet();
        Iterator i1 = unsortedSet.iterator();
        while (i1.hasNext()) {
            Map.Entry mapEntry = (Map.Entry) i1.next();
            System.out.println("Key: " + mapEntry.getKey() + " - Value: " + mapEntry.getValue());
        }
        
        // call method valueSort() and assign the output to sortedMap
        Map sortedMap = valueSort(map);
        System.out.println(sortedMap);
        
        // Display elements after sorting 
        Set sortedSet = sortedMap.entrySet();
        Iterator i2 = sortedSet.iterator();
        while (i2.hasNext()) {
            Map.Entry mapEntry = (Map.Entry) i2.next();
            System.out.println("Key: " + mapEntry.getKey() + " - Value: " + mapEntry.getValue());
        }
    }
}
import java.util.Scanner;
class Mark{
	private int markM1,markM2,markM3;
	private int totalMark,percentage;
	void input(){
		Scanner sc=new Scanner(System.in);
		System.out.println("Enter your Mark of the 1st Subject:");
		markM1=sc.nextInt();
		System.out.println("Enter your Mark of the 2nd Subject:");
		markM2=sc.nextInt();
		System.out.println("Enter your Mark of the 3rd Subject:");
		markM3=sc.nextInt();
	}
	private void markObtain(){
		totalMark=markM1+markM2+markM3;
		percentage=(300/totalMark)*100;
	}
	void output(){
		markObtain();
		System.out.println("Mark Obtain in 1st Subject: "+markM1);
		System.out.println("Mark Obtain in 2nd Subject: "+markM2);
		System.out.println("Mark Obtain in 1st Subject: "+markM3);
		System.out.println("Total-Mark= "+totalMark);
		System.out.println("percentage= "+percentage);
	}
}
class Student{
	private int rollNumber;
	private String name;
	private Mark m=new Mark();
	void input(){
		Scanner sc=new Scanner(System.in);
		System.out.println("Enter your ROLL-NUMBER:");
		rollNumber=sc.nextInt();
		sc.nextLine();
		System.out.println("Enter your NAME:");
		name=sc.nextLine();
		m.input();
	}
	void output(){
		System.out.println("Roll: "+rollNumber);
		System.out.println("Name: "+name);
		m.output();
	}
}
class StudentInfo{
	public static void main(String args[]){
		Student s=new Student();
		s.input();
		s.output();
	}
}
public class Exercise31 {
    public static void main(String[] args) {
        // Display Java version
        System.out.println("\nJava Version: " + System.getProperty("java.version"));
        
        // Display Java runtime version
        System.out.println("Java Runtime Version: " + System.getProperty("java.runtime.version"));
        
        // Display Java home directory
        System.out.println("Java Home: " + System.getProperty("java.home"));
        
        // Display Java vendor name
        System.out.println("Java Vendor: " + System.getProperty("java.vendor"));
        
        // Display Java vendor URL
        System.out.println("Java Vendor URL: " + System.getProperty("java.vendor.url"));
        
        // Display Java class path
        System.out.println("Java Class Path: " + System.getProperty("java.class.path") + "\n");
    }
}


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

{
    "error": {
        "message": "You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.",
        "type": "insufficient_quota",
        "param": null,
        "code": "insufficient_quota"
    }
}



{"user":{"id":"user-LXaUaVde1TljvzyYdEys8fm5","name":"qncity7ahqv@gmail.com","email":"qncity7ahqv@gmail.com","image":"https://s.gravatar.com/avatar/66eff1ca1d13687c8ddefaff7679f78d?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fqn.png","picture":"https://s.gravatar.com/avatar/66eff1ca1d13687c8ddefaff7679f78d?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fqn.png","idp":"auth0","iat":1699936137,"mfa":false,"groups":[],"intercom_hash":"2ead6d0bbdb6f983f7be9e9581677eb3432ef8c4bb74b2e38cd8ecff0ee2e52b"},"expires":"2024-02-14T09:39:28.424Z","accessToken":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik1UaEVOVUpHTkVNMVFURTRNMEZCTWpkQ05UZzVNRFUxUlRVd1FVSkRNRU13UmtGRVFrRXpSZyJ9.eyJodHRwczovL2FwaS5vcGVuYWkuY29tL3Byb2ZpbGUiOnsiZW1haWwiOiJxbmNpdHk3YWhxdkBnbWFpbC5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZX0sImh0dHBzOi8vYXBpLm9wZW5haS5jb20vYXV0aCI6eyJwb2lkIjoib3JnLTVncDlXTGwwODJhMUtVQ1BaWXlVTHliViIsInVzZXJfaWQiOiJ1c2VyLUxYYVVhVmRlMVRsanZ6eVlkRXlzOGZtNSJ9LCJpc3MiOiJodHRwczovL2F1dGgwLm9wZW5haS5jb20vIiwic3ViIjoiYXV0aDB8NjNmMTAzODIxODA1NDg3OTZjMWU0Y2ZmIiwiYXVkIjpbImh0dHBzOi8vYXBpLm9wZW5haS5jb20vdjEiLCJodHRwczovL29wZW5haS5vcGVuYWkuYXV0aDBhcHAuY29tL3VzZXJpbmZvIl0sImlhdCI6MTY5OTkzNjEzNywiZXhwIjoxNzAwODAwMTM3LCJhenAiOiJUZEpJY2JlMTZXb1RIdE45NW55eXdoNUU0eU9vNkl0RyIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgZW1haWwgbW9kZWwucmVhZCBtb2RlbC5yZXF1ZXN0IG9yZ2FuaXphdGlvbi5yZWFkIG9yZ2FuaXphdGlvbi53cml0ZSBvZmZsaW5lX2FjY2VzcyJ9.KPJeQd6-dnaRca4JLrxtF-0h4ZM5igA7_ard9GkJ_JZVY1rz9QjTzW4gm0xuZd78qf1XWtn9SzIAU0WXlmjIDKe4plREIdcleWca_ClSl49SdeuRUy1XvH6BEU-OKagwoNVkIzbAsGX1duxxYLPUX-Hu94v3cnF6d9yIRX0UUUWyF-mar5QWeHvQrA9KcYmqOgEvT2AM20KlzKpJ51RZiGNssjRm3ZWGGO5AMdl8xpNbOOf4L5_Dnf_KKFKpV48n-JqCRCT_yeOPEz0SWNFI2kMVQgpfP5MpR6xl7tIEZ3Tn40qVc2wSx0GWHw960Q_mRZYmqb-ClguFpsMo-c6pfw","authProvider":"auth0"}
import java.util.*;
import java.net.*;
import java.io.*;

public class Server {

    public static void main(String[] args) {

        for (String portStr : args) {
            try {
                int port = Integer.parseInt(portStr);
                new Thread(new ServerTask(port)).start();
            } catch (NumberFormatException e) {
                System.out.println("Incorrect port: " + portStr);
            }
        }
    }

    private static class ServerTask implements Runnable {
        private int port;

        public ServerTask(int port) {
            this.port = port;
        }

        public void run() {
            try (ServerSocket serverSocket = new ServerSocket(port)) {
                while (true) {
                    Socket clientSocket = serverSocket.accept();
                    new Thread(new ClientHandler(clientSocket)).start();
                }
            } catch (IOException e) {
                System.out.println("Error starting the server on port " + port);
            }
        }
    }

    private static class ClientHandler implements Runnable {
        private Socket clientSocket;

        public ClientHandler(Socket clientSocket) {
            this.clientSocket = clientSocket;
        }

        public void run() {
            try (InputStream input = clientSocket.getInputStream()) {
                byte[] buffer = new byte[20];
                int bytesRead = input.read(buffer);

                String receiveData = new String(buffer, 0, bytesRead);
                System.out.println(receiveData);
            } catch (IOException e) {
                System.out.println("Error receiving data from client");
                e.printStackTrace();
            } finally {
                try {
                    clientSocket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
import java.util.*;
import java.net.*;
import java.io.*;
import util.SocketFactory;

class Main
{
    public static void main(String[] args) throws IOException
    {
        byte[] data  = new byte[20];
        String output = "";

        ServerSocket socket = SocketFactory.buildSocket();

        Socket clientSocket = socket.accept(); //oczekiwanie na polaczenie, oraz akceptacja

        InputStream input = clientSocket.getInputStream();
        
        input.read(data, 0, 20);
        output = new String(data, 0, 20);
        System.out.println(output);


    }
}
import java.util.*;
import java.net.*;
import java.io.*;

class Sock{
    public static String getFlag(String hostName, Integer port){
        int bufferSize = 20;
        byte[] data = new byte[bufferSize];
        String output = "";

        try{
            Socket socket = new Socket(hostName, port);
            for(int i = 0; i < bufferSize; i++){
                if(socket.getInputStream().read(data, i, 1) <= 0){
                    break;
                }
            //socket.getInputStream().read(data, i, 1); //0 to indeks gdzie zaczynay,
            output = output + (char) data[i]; 
            }
            socket.close();
        }
        catch(IOException e){
            System.out.println(e);
        }

        return output;
    }
}

class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        Integer port = scan.nextInt();

        System.out.println(Sock.getFlag("127.0.0.1", port)); //wyprintuje SUCCESS

    }
}
import java.util.*;
import java.net.*;
import java.io.*;

class Sock{
    public static String getFlag(String hostName, Integer port){
        byte[] data = new byte[20];
        try{
            Socket socket = new Socket(hostName, port);
            socket.getInputStream().read(data, 0, 20); //0 to indeks gdzie zaczynay,
            socket.close();
        }
        catch(IOException e){
            System.out.println(e);
        }

        return new String(data, 0, 20);
    }
}

class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        Integer port = scan.nextInt();

        System.out.println(Sock.getFlag("127.0.0.1", port)); //wyprintuje SUCCESS

    }
}
<!DOCTYPE html>
<html>
  <head>
      <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
      <title>Spring Boot WebSocket Chat Application | CalliCoder</title>
      <link rel="stylesheet" href="css/main.css" />
  </head>
  <body>
    <noscript>
      <h2>Sorry! Your browser doesn't support Javascript</h2>
    </noscript>

    <div id="username-page">
        <div class="username-page-container">
            <h1 class="title">Type your username</h1>
            <form id="usernameForm" name="usernameForm">
                <div class="form-group">
                    <input type="text" id="name" placeholder="Username" autocomplete="off" class="form-control" />
                </div>
                <div class="form-group">
                    <button type="submit" class="accent username-submit">Start Chatting</button>
                </div>
            </form>
        </div>
    </div>

    <div id="chat-page" class="hidden">
        <div class="chat-container">
            <div class="chat-header">
                <h2>Spring WebSocket Chat Demo</h2>
            </div>
            <div class="connecting">
                Connecting...
            </div>
            <ul id="messageArea">

            </ul>
            <form id="messageForm" name="messageForm" nameForm="messageForm">
                <div class="form-group">
                    <div class="input-group clearfix">
                        <input type="text" id="message" placeholder="Type a message..." autocomplete="off" class="form-control"/>
                        <button type="submit" class="primary">Send</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.1.4/sockjs.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"></script>
    <script src="js/main.js"></script>
  </body>
</html>

------------------------------------
pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.example</groupId>
	<artifactId>websocket-demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>websocket-demo</name>
	<description>Spring Boot WebSocket Chat Demo</description>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.5.5</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>11</java.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-websocket</artifactId>
		</dependency>

		<!-- RabbitMQ Starter Dependency (Not required if you're using the simple in-memory broker for STOMP) -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-amqp</artifactId>
		</dependency>

		<!-- Following dependency is required for Full Featured STOMP Broker Relay -->
		<dependency>
		    <groupId>org.springframework.boot</groupId>
		    <artifactId>spring-boot-starter-reactor-netty</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<scope>runtime</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
			<!-- This plugin is used to create a docker image and publish the image to docker hub-->
			<plugin>
				<groupId>com.spotify</groupId>
				<artifactId>dockerfile-maven-plugin</artifactId>
				<version>1.4.0</version>
				<configuration>
					<!-- replace `callicoder` with your docker id-->
					<repository>callicoder/spring-boot-websocket-chat-demo</repository>
					<tag>${project.version}</tag>
					<buildArgs>
						<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
					</buildArgs>
				</configuration>
				<executions>
					<execution>
						<id>default</id>
						<phase>install</phase>
						<goals>
							<goal>build</goal>
							<goal>push</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>
--------------------------------------

static/js/main.js

'use strict';

var usernamePage = document.querySelector('#username-page');
var chatPage = document.querySelector('#chat-page');
var usernameForm = document.querySelector('#usernameForm');
var messageForm = document.querySelector('#messageForm');
var messageInput = document.querySelector('#message');
var messageArea = document.querySelector('#messageArea');
var connectingElement = document.querySelector('.connecting');

var stompClient = null;
var username = null;

var colors = [
    '#2196F3', '#32c787', '#00BCD4', '#ff5652',
    '#ffc107', '#ff85af', '#FF9800', '#39bbb0'
];

function connect(event) {
    username = document.querySelector('#name').value.trim();

    if(username) {
        usernamePage.classList.add('hidden');
        chatPage.classList.remove('hidden');

        var socket = new SockJS('/ws');
        stompClient = Stomp.over(socket);

        stompClient.connect({}, onConnected, onError);
    }
    event.preventDefault();
}

function onConnected() {
    // Subscribe to the Public Topic
    stompClient.subscribe('/topic/public', onMessageReceived);

    // Tell your username to the server
    stompClient.send("/app/chat.addUser",
        {},
        JSON.stringify({sender: username, type: 'JOIN'})
    )

    connectingElement.classList.add('hidden');
}


function onError(error) {
    connectingElement.textContent = 'Could not connect to WebSocket server. Please refresh this page to try again!';
    connectingElement.style.color = 'red';
}


async function sendMessage(event) {
    var messageContent = messageInput.value.trim();

    if(messageContent && stompClient) {
        var chatMessage = {
            sender: username,
            content: messageInput.value,
            type: 'CHAT'
        };

        stompClient.send("/app/chat.sendMessage", {}, JSON.stringify(chatMessage));
        messageInput.value = '';
    }
    event.preventDefault();
}


function onMessageReceived(payload) {
    var message = JSON.parse(payload.body);

    var messageElement = document.createElement('li');

    console.log(payload)
    if(message.type === 'JOIN') {
        messageElement.classList.add('event-message');
        message.content = message.sender + ' joined!';
    } else if (message.type === 'LEAVE') {
        messageElement.classList.add('event-message');
        message.content = message.sender + ' left!';
    } else {
        messageElement.classList.add('chat-message');

        var avatarElement = document.createElement('i');
        var avatarText = document.createTextNode(message.sender[0]);
        avatarElement.appendChild(avatarText);
        avatarElement.style['background-color'] = getAvatarColor(message.sender);

        messageElement.appendChild(avatarElement);

        var usernameElement = document.createElement('span');
        var usernameText = document.createTextNode(message.sender);
        usernameElement.appendChild(usernameText);
        messageElement.appendChild(usernameElement);
    }

    var textElement = document.createElement('p');
    var messageText = document.createTextNode(message.content);
    textElement.appendChild(messageText);

    messageElement.appendChild(textElement);

    messageArea.appendChild(messageElement);
    messageArea.scrollTop = messageArea.scrollHeight;
}


function getAvatarColor(messageSender) {
    var hash = 0;
    for (var i = 0; i < messageSender.length; i++) {
        hash = 31 * hash + messageSender.charCodeAt(i);
    }

    var index = Math.abs(hash % colors.length);
    return colors[index];
}

usernameForm.addEventListener('submit', connect, true)
messageForm.addEventListener('submit', sendMessage, true)
static/css/main.css

* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

html,body {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    padding: 0;
    font-weight: 400;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.58;
    color: #333;
    background-color: #f4f4f4;
    height: 100%;
}

body:before {
    height: 50%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: #128ff2;
    content: "";
    z-index: 0;
}

.clearfix:after {
    display: block;
    content: "";
    clear: both;
}

.hidden {
    display: none;
}

.form-control {
    width: 100%;
    min-height: 38px;
    font-size: 15px;
    border: 1px solid #c8c8c8;
}

.form-group {
    margin-bottom: 15px;
}

input {
    padding-left: 10px;
    outline: none;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 20px;
    margin-bottom: 20px;
}

h1 {
    font-size: 1.7em;
}

a {
    color: #128ff2;
}

button {
    box-shadow: none;
    border: 1px solid transparent;
    font-size: 14px;
    outline: none;
    line-height: 100%;
    white-space: nowrap;
    vertical-align: middle;
    padding: 0.6rem 1rem;
    border-radius: 2px;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    min-height: 38px;
}

button.default {
    background-color: #e8e8e8;
    color: #333;
    box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.12);
}

button.primary {
    background-color: #128ff2;
    box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.12);
    color: #fff;
}

button.accent {
    background-color: #ff4743;
    box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.12);
    color: #fff;
}

#username-page {
    text-align: center;
}

.username-page-container {
    background: #fff;
    box-shadow: 0 1px 11px rgba(0, 0, 0, 0.27);
    border-radius: 2px;
    width: 100%;
    max-width: 500px;
    display: inline-block;
    margin-top: 42px;
    vertical-align: middle;
    position: relative;
    padding: 35px 55px 35px;
    min-height: 250px;
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    margin: 0 auto;
    margin-top: -160px;
}

.username-page-container .username-submit {
    margin-top: 10px;
}


#chat-page {
    position: relative;
    height: 100%;
}

.chat-container {
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    background-color: #fff;
    box-shadow: 0 1px 11px rgba(0, 0, 0, 0.27);
    margin-top: 30px;
    height: calc(100% - 60px);
    max-height: 600px;
    position: relative;
}

#chat-page ul {
    list-style-type: none;
    background-color: #FFF;
    margin: 0;
    overflow: auto;
    overflow-y: scroll;
    padding: 0 20px 0px 20px;
    height: calc(100% - 150px);
}

#chat-page #messageForm {
    padding: 20px;
}

#chat-page ul li {
    line-height: 1.5rem;
    padding: 10px 20px;
    margin: 0;
    border-bottom: 1px solid #f4f4f4;
}

#chat-page ul li p {
    margin: 0;
}

#chat-page .event-message {
    width: 100%;
    text-align: center;
    clear: both;
}

#chat-page .event-message p {
    color: #777;
    font-size: 14px;
    word-wrap: break-word;
}

#chat-page .chat-message {
    padding-left: 68px;
    position: relative;
}

#chat-page .chat-message i {
    position: absolute;
    width: 42px;
    height: 42px;
    overflow: hidden;
    left: 10px;
    display: inline-block;
    vertical-align: middle;
    font-size: 18px;
    line-height: 42px;
    color: #fff;
    text-align: center;
    border-radius: 50%;
    font-style: normal;
    text-transform: uppercase;
}

#chat-page .chat-message span {
    color: #333;
    font-weight: 600;
}

#chat-page .chat-message p {
    color: #43464b;
}

#messageForm .input-group input {
    float: left;
    width: calc(100% - 85px);
}

#messageForm .input-group button {
    float: left;
    width: 80px;
    height: 38px;
    margin-left: 5px;
}

.chat-header {
    text-align: center;
    padding: 15px;
    border-bottom: 1px solid #ececec;
}

.chat-header h2 {
    margin: 0;
    font-weight: 500;
}

.connecting {
    padding-top: 5px;
    text-align: center;
    color: #777;
    position: absolute;
    top: 65px;
    width: 100%;
}


@media screen and (max-width: 730px) {

    .chat-container {
        margin-left: 10px;
        margin-right: 10px;
        margin-top: 10px;
    }
}

@media screen and (max-width: 480px) {
    .chat-container {
        height: calc(100% - 30px);
    }

    .username-page-container {
        width: auto;
        margin-left: 15px;
        margin-right: 15px;
        padding: 25px;
    }

    #chat-page ul {
        height: calc(100% - 120px);
    }

    #messageForm .input-group button {
        width: 65px;
    }

    #messageForm .input-group input {
        width: calc(100% - 70px);
    }

    .chat-header {
        padding: 10px;
    }

    .connecting {
        top: 60px;
    }

    .chat-header h2 {
        font-size: 1.1em;
    }
}



config/WebSocketConfig

package com.example.websocketdemo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.*;

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/ws").withSockJS();
    }


    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
        registry.setApplicationDestinationPrefixes("/app");
        registry.enableSimpleBroker("/topic");

    }
}


---------------------------------------------
  
controller/ChatController

package com.example.websocketdemo.controller;

import com.example.websocketdemo.model.ChatMessage;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
import org.springframework.stereotype.Controller;


@Controller
public class ChatController {

    @MessageMapping("/chat.sendMessage")
    @SendTo("/topic/public")
    public ChatMessage sendMessage(@Payload ChatMessage chatMessage) {
        return chatMessage;
    }

    @MessageMapping("/chat.addUser")
    @SendTo("/topic/public")
    public ChatMessage addUser(@Payload ChatMessage chatMessage,
                               SimpMessageHeaderAccessor headerAccessor) {
        // Add username in web socket session
        headerAccessor.getSessionAttributes().put("username", chatMessage.getSender());
        return chatMessage;
    }

}

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

controller/WebSocketEventListener

package com.example.websocketdemo.controller;

import com.example.websocketdemo.model.ChatMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.messaging.SessionConnectedEvent;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;

@Component
public class WebSocketEventListener {

    private static final Logger logger = LoggerFactory.getLogger(WebSocketEventListener.class);

    @Autowired
    private SimpMessageSendingOperations messagingTemplate;

    @EventListener
    public void handleWebSocketConnectListener(SessionConnectedEvent event) {
        logger.info("Received a new web socket connection");
    }

    @EventListener
    public void handleWebSocketDisconnectListener(SessionDisconnectEvent event) {
        StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(event.getMessage());

        String username = (String) headerAccessor.getSessionAttributes().get("username");
        if(username != null) {
            logger.info("User Disconnected : " + username);

            ChatMessage chatMessage = new ChatMessage();
            chatMessage.setType(ChatMessage.MessageType.LEAVE);
            chatMessage.setSender(username);

            messagingTemplate.convertAndSend("/topic/public", chatMessage);
        }
    }
}

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

model/ChatMessage
package com.example.websocketdemo.model;

import lombok.Data;

@Data
public class ChatMessage {
    private MessageType type;
    private String content;
    private String sender;

    public enum MessageType {
        CHAT,
        JOIN,
        LEAVE
    }
}

-----------------------------------
WebsocketDemoApplication

package com.example.websocketdemo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class WebsocketDemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(WebsocketDemoApplication.class, args);
	}
}
public class Student {
	
	private String name;
	private int age;
	private int id;
	private double gpa;
	int foo;
	
	Student(String name, int age, int id) {
		this.name = name;
		this.age = age;
		this.id = id;
		gpa = 0.0;
		foo = 0;
	}
//Get
	public String getName() {
		return name;
	}
	
	public int getAge() {
		return age;
	}
	public int getId() {
		return id;
	}
	public double getGpa() {
		return gpa;
	}
//Set
	public void setName(String name) {
		this.name = name;
	}
	public void setAge (int age) {
		this.age = age;
	}
	public void setId(int id) {
		this.id = id;
	}
	public void setGpa(double gpa) {
		this.gpa = gpa;
	}
	
	public String toString() {
		return "Name: " + name + " Age: " + age + " Id: " + id + " Gpa: " + gpa;
	}

}

public static void main(String[] args) {
		
		Student s1 = new Student("Mohamed", 24, 210209327);
		
		s1.setGpa(98.67);
		
		System.out.println("Student Name: " + s1.getName());
		System.out.println("Student Age: " + s1.getAge());
		System.out.println("Student Id: " + s1.getId());
		System.out.println("Student Gpa: " + s1.getGpa());
		
		System.out.println(s1.toString());
		
		s1.foo = 5;
		System.out.println("Student foo: " + s1.foo);

	}

}
//OUTPUT:
Student Name: Mohamed
Student Age: 24
Student Id: 210209327
Student Gpa: 98.67
Name: Mohamed Age: 24 Id: 210209327 Gpa: 98.67
Student foo: 5
import java.util.Scanner;
class Student{
	int rollNumber;
	String name;
}
class StudentInfo{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		Student s1=new Student();
		Student s2=new Student();
		Student s3=new Student();
		System.out.println("Enter roll of 1st Student:");
		s1.rollNumber=sc.nextInt();
		sc.nextLine();
		System.out.println("Enter name of 1st Student:");
		s1.name=sc.nextLine();
		System.out.println("Enter roll of 2nd Student:");
		s2.rollNumber=sc.nextInt();
		sc.nextLine();
		System.out.println("Enter name of 2nd Student:");
		s2.name=sc.nextLine();
		System.out.println("Enter roll of 3rd Student:");
		s3.rollNumber=sc.nextInt();
		sc.nextLine();
		System.out.println("Enter name of 3rd Student:");
		s3.name=sc.nextLine();
		System.out.println("Name of First Student= "+s1.name);
		System.out.println("roll of First Student= "+s1.rollNumber);
		System.out.println("Name of Second Student= "+s2.name);
		System.out.println("roll of Second Student= "+s2.rollNumber);
		System.out.println("Name of Third Student= "+s3.name);
		System.out.println("roll of Second Student= "+s3.rollNumber);
	}
}
import java.util.Scanner;
class Student{
	int rollNumber;
	String name;
}
class StudentInfo{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		Student s1=new Student();
		Student s2=new Student();
		Student s3=new Student();
		System.out.println("Enter roll of 1st Student:");
		s1.rollNumber=sc.nextInt();
		sc.nextLine();
		System.out.println("Enter name of 1st Student:");
		s1.name=sc.nextLine();
		System.out.println("Enter roll of 2nd Student:");
		s2.rollNumber=sc.nextInt();
		sc.nextLine();
		System.out.println("Enter name of 2nd Student:");
		s2.name=sc.nextLine();
		System.out.println("Enter roll of 3rd Student:");
		s3.rollNumber=sc.nextInt();
		sc.nextLine();
		System.out.println("Enter name of 3rd Student:");
		s3.name=sc.nextLine();
		System.out.println("Name of First Student= "+s1.name);
		System.out.println("roll of First Student= "+s1.rollNumber);
		System.out.println("Name of Second Student= "+s2.name);
		System.out.println("roll of Second Student= "+s2.rollNumber);
		System.out.println("Name of Third Student= "+s3.name);
		System.out.println("roll of Second Student= "+s3.rollNumber);
	}
}
import java.util.Scanner;
public class AriOp{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int FirstNumber,SecondNumber,x;
		int sum,sub,multi,div,mod,temp;
		System.out.println("ARITHMETIC OPERATION");
		System.out.println("--------------------");
		System.out.println("1.ADDITION");
		System.out.println("2.SUBTRACTION");
		System.out.println("3.MULTIPLICATION");
		System.out.println("4.DIVISION");
		System.out.println("5.REMAINDER");
		System.out.println("---------------------");
		System.out.println("Enter a number:");
		FirstNumber=sc.nextInt();
		System.out.println("Enter a number:");
		SecondNumber=sc.nextInt();
		System.out.println("Enter your option:");
		x=sc.nextInt();
		if(x>5){
			System.out.println("Enter valid criteria mentioned Above");
		}else{
			if(x==1){
				sum=FirstNumber+SecondNumber;
				System.out.println("Sum= "+sum);
			}else if(x==2){
				if(FirstNumber<SecondNumber){
						temp=FirstNumber;
						FirstNumber=SecondNumber;
						SecondNumber=temp;
				}
				sub=FirstNumber-SecondNumber;
				System.out.println("sub= "+sub);
			}else if(x==3){
				multi=FirstNumber*SecondNumber;
				System.out.println("multi= "+multi);
			}else if(x==4){
				if(FirstNumber<SecondNumber){
						System.out.println("Not Possible");
				}else{
					div=FirstNumber/SecondNumber;
					System.out.println("Div= "+div);
				}
			}else{
				mod=FirstNumber%SecondNumber;
				System.out.println("modulus= "+mod);
			}
		}
	}
}
Answer 1:

import java.util.Scanner;

public class Movie {
	
	String title;
	int rating;
	
	public Movie(String newTitle, int newRating) {
		title = newTitle;
		if(newRating >=0 && newRating <= 10) {
			rating = newRating;
		}
	}
	public char getCategory() {
		if(rating ==9 || rating == 10)
			return 'A';
		else if(rating == 7 || rating ==8)
			return 'B';
		else if(rating == 5 || rating == 6)
			return 'C';
		else if(rating == 3 || rating ==4)
			return 'D';
		else 
			return 'F';
		
	}
	public void writeOutput() {
		System.out.println("Title: " + title);
		System.out.println("Rating: " + rating);
	}

	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		System.out.println("Enter Title of Movie: ");
		String name = scanner.next();
		
		System.out.println("Enter Rating a Movie: ");
		int rating = scanner.nextInt();
		
		Movie m1 = new Movie(name, rating);
		
		//getCategory();
		m1.writeOutput();
		System.out.println("Catagory of the movie: " + m1.getCategory());
		
	}
}
//OUTPUT:

Enter Title of Movie: 
Black_List
Enter Rating a Movie: 
10
Title: Black_List
Rating: 10
Catagory of the movie: A

Answer 4:

import java.util.Scanner;

public class Employee {
	
	String name;
	double salary;
	double hours;
	
	Employee(){
		this("",0,0);
	}
	Employee(String name, double salary, double hours){
		this.name = name;
		this.salary = salary;
		this.hours = hours;
	}
	
	public void addBonus() {
		if(salary < 600) {
			salary += 15;
		}
	}
	public void addWork() {
		if(hours > 8) {
			salary += 10;
		}
	}
	public void printSalary() {
		System.out.println("Final Salary Of The Employee = " + salary + "$");
	}

	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		System.out.println("Enter a Name of Employee:");
		String name = scanner.next();
		System.out.println("Enter a Salary of Employee: ");
		double sal = scanner.nextDouble();
		
		System.out.println("Enter a Number of Hours:");
		double hrs = scanner.nextDouble();
		
		Employee emp = new Employee(name,sal,hrs);
		
		emp.addBonus();
		emp.addWork();
		emp.printSalary();

	}
}
//OUTPUT:
Enter a Name of Employee:
mohamed
Enter a Salary of Employee: 
599
Enter a Number of Hours:
10
Final Salary Of The Employee = 624.0$


Q 1.
#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 3

int stack [MAX_SIZE];
int top = -1;

void push(int value) 
{
    if(top==MAX_SIZE-1) {
        printf("Stack Overflow (Full): Cannot Push Element (%d) onto the stack.\n", value);
    }
    else {
        top++;
        stack[top] = value;
        printf("Element (%d) Pushed Onto The Stack.\n", value);
    }
}

void pop() 
{
    if(top == -1) {
        printf("Stack Underflow (Empty): Cannot Pop Element From The Stack.\n");
    }
    else {
        printf("\nElement (%d) Popped From The Stack.\n", stack[top]);
        top--;
    }
}

void display()
{
    if(top == -1) {
        printf("Stack is Empty.\n");
    }
    else {
        printf("Stack Elements are: ");
        for(int i=top; i>=0; i--) {
            printf("%d, ",stack[i]);
        }
        printf("\n");
    }
}

int main() {
    
    push(10);
    push(20);
    display();
    push(50);
    push(100);
    display();

    pop();
    display();
    pop();
    pop();
    display();

    return 0;
}

//OUTPUT:
Element (10) Pushed Onto The Stack.
Element (20) Pushed Onto The Stack.
Stack Elements are: 20, 10, 
Element (50) Pushed Onto The Stack.
Stack Overflow (Full): Cannot Push Element (100) onto the stack.
Stack Elements are: 50, 20, 10, 

Element (50) Popped From The Stack.
Stack Elements are: 20, 10, 

Element (20) Popped From The Stack.

Element (10) Popped From The Stack.
Stack is Empty.


Q3. 
#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 100

char stack[MAX_SIZE];
int top = -1;
void push(char data) {
    if (top == MAX_SIZE - 1) {
        printf("Overflow stack!\n");
        return;
    }
    top++;
    stack[top] = data;
}

char pop() {
    if (top == -1) {
        printf("Empty stack!\n");
        return ' ';
    }
    char data = stack[top];
    top--;
    return data;
}

int is_matching_pair(char char1, char char2) {
    if (char1 == '(' && char2 == ')') {
        return 1;
    } else if (char1 == '[' && char2 == ']') {
        return 1;
    } else if (char1 == '{' && char2 == '}') {
        return 1;
    } else {
        return 0;
    }
}
int isBalanced(char* text) {
    int i;
    for (i = 0; i < strlen(text); i++) {
        if (text[i] == '(' || text[i] == '[' || text[i] == '{') {
            push(text[i]);
        } else if (text[i] == ')' || text[i] == ']' || text[i] == '}') {
            if (top == -1) {
                return 0;
            } else if (!is_matching_pair(pop(), text[i])) {
                return 0;
            }
        }
    }
    if (top == -1) {
        return 1;
    } else {
        return 0;
    }
}

int main() {
   char text[MAX_SIZE];
   printf("Input an expression in parentheses: ");
   scanf("%s", text);
   if (isBalanced(text)) {
       printf("The expression is balanced.\n");
   } else {
       printf("The expression is not balanced.\n");
   }
   return 0;
}
//OUTPUT:
Input an expression in parentheses: {[({[]})]}
The expression is balanced.
Input an expression in parentheses: [{[}]]
The expression is not balanced.
public class Car {
	
	String model;
	String color;
	int speed;
	
//Default Constructor
	
	public Car() {
		model = "Toyota";
		color = "black";
		speed = 40;
	}
	
	public Car(String newModel, String newColor, int newSpeed) {
		model= newModel;
		color = newColor;
		speed = newSpeed;
	} 
	
	public void increaseSpeed(int newSpeed) {
		speed = speed + newSpeed;
	}
	
	public void decreaseSpeed(int newSpeed) {
		speed = speed - newSpeed;
	}
	
//Test programming
	public static void main(String[] args) {
	
//Car 1
		Car c1 = new Car();
		System.out.println("Car 1:");
		System.out.println("\nModel: " + c1.model + "\nColor: " + c1.color + "\nspeed: " + c1.speed);
	
		c1.increaseSpeed(100);
		
		System.out.println("\nCar 1: İncrease speed by (100)");
		System.out.println("New speed: " + c1.speed);
		
		c1.decreaseSpeed(50);
		
		System.out.println("\nCar 1: Decrease speed by (50)");
		System.out.println("New speed: " + c1.speed);
	
//CAR 2
		Car c2 = new Car("Bugati", "Blue", 100);
		
		System.out.println("\n\nCar 2:");
		
		System.out.println("\nModel: " + c2.model + "\nColor: " + c2.color + "\nspeed: " + c2.speed);
	
	
		
        c2.increaseSpeed(90);
		
		System.out.println("\nCar 2: İncrease speed by (90)");
		System.out.println("New speed: " + c2.speed);
		
		c2.decreaseSpeed(40);
		
		System.out.println("\nCar 2: Decrease speed by (40)");
		System.out.println("New speed: " + c2.speed);
	
	
	}

}
//OUTPUT:
Car 1:

Model: Toyota
Color: black
speed: 40

Car 1: İncrease speed by (100)
New speed: 140

Car 1: Decrease speed by (50)
New speed: 90


Car 2:

Model: Bugati
Color: Blue
speed: 100

Car 2: İncrease speed by (90)
New speed: 190

Car 2: Decrease speed by (40)
New speed: 150



///.                     BANK ACCOUNT CALSSES AND ABOJECTS.


import java.util.Scanner;

public class BankAccount {
	
	String owner;
	double balance;
	int aType;
	
	public BankAccount() {
		owner = "Mohamed";
		balance = 1500;
		aType = 1;
		
	}
	public BankAccount(String newOwner, double newBalance, int newAType ) {
		owner = newOwner;
		balance = newBalance;
		aType = newAType;
	}
		
	public void addMoney(double newBalance) {
		balance = balance + newBalance;
	}
	
	public void takeMoney(double newBalance) {
		balance = balance - newBalance;
	}
	
	public static void main (String[] arg) {
	
		BankAccount c1 = new BankAccount();
		
		System.out.println("Costumer 1:");
		System.out.println("\nOwner: " +c1.owner + "\nBalance: " + c1.balance + "\naType: " + c1.aType);
		
		c1.addMoney(1500);
		System.out.println("\nAdd Blance by (1500)");
		System.out.println("\nNew Balance :" + c1.balance);
		
		c1.takeMoney(2500);
		System.out.println("\nRemove Blance by (2500)");
		System.out.println("\nNew Balance :" + c1.balance);
		
		Scanner scanner = new Scanner(System.in);
		
		System.out.println("\nEnter Costumer 2 information: ");
		System.out.println("Enter Name of Owner : ");
		String owner = scanner.next();
		
		System.out.println("Enter balance: ");
		double balance = scanner.nextDouble();
		
		System.out.println("Enter AType Account: ");
		int aType = scanner.nextInt();
		
		BankAccount c2 = new BankAccount(owner, balance, aType);
		
		System.out.println("\n\nCostumer 2:");
		System.out.println("\nOwner: " +c2.owner + "\nBalance: " + c2.balance + "\naType: " + c2.aType);
		
		c2.addMoney(3000);
		System.out.println("\nAdd Blance by (3000)");
		System.out.println("\nNew Balance :" + c2.balance);
		
		c2.takeMoney(5000);
		System.out.println("\nRemove Blance by (5000)");
		System.out.println("\nNew Balance :" + c2.balance);
		
		scanner.close();
	}
}
//OUTPUT: 
Costumer 1:

Owner: Mohamed
Balance: 1500.0
aType: 1

Add Blance by (1500)

New Balance :3000.0

Remove Blance by (2500)

New Balance :500.0

Enter Costumer 2 information: 
Enter Name of Owner : 
NAJMA
Enter balance: 
8000
Enter AType Account: 
2


Costumer 2:

Owner: NAJMA
Balance: 8000.0
aType: 2

Add Blance by (3000)

New Balance :11000.0

Remove Blance by (5000)

New Balance :6000.0

public class ThisExample {

	
	int a = 10;      //instance variable
	void display() 
	{
		int a = 200;      //Local variable
      
		System.out.println("Local Variable = " + a);
		System.out.println("İnstance variable = " + this.a);
	}
	
	public static void main(String[] args) {
		
		ThisExample obj = new ThisExample();
		obj.display();

	}

}
//Output: 
Local Variable = 200
İnstance variable = 10
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".RegisterActivity"
    android:background="@drawable/back2">

    <EditText
        android:id="@+id/editTextRegPassword"
        android:layout_width="330dp"
        android:layout_height="53dp"
        android:layout_marginTop="28dp"
        android:background="@drawable/input_bg"
        android:drawableLeft="@drawable/ic_baseline_security_24"
        android:ems="10"
        android:hint="Password"
        android:inputType="textPersonName"
        android:paddingLeft="20dp"
        android:paddingTop="10dp"
        android:paddingRight="10dp"
        android:paddingBottom="10dp"
        android:text="Password"
        android:textColor="#FFFFFF"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.493"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editTextRegemail" />

    <EditText
        android:id="@+id/editTextRegConfirmPassword"
        android:layout_width="330dp"
        android:layout_height="53dp"
        android:layout_marginTop="28dp"
        android:background="@drawable/input_bg"
        android:drawableLeft="@drawable/ic_baseline_security_24"
        android:ems="10"
        android:hint="Password"
        android:inputType="textPersonName"
        android:paddingLeft="20dp"
        android:paddingTop="10dp"
        android:paddingRight="10dp"
        android:paddingBottom="10dp"
        android:text="Confirm Password"
        android:textColor="#FFFFFF"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.493"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editTextRegPassword" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="227dp"
        android:layout_height="58dp"
        android:selectAllOnFocus="true"
        android:shadowColor="#000000"
        android:text="HealthCare"
        android:textAlignment="center"
        android:textAppearance="@style/TextAppearance.AppCompat.Body1"
        android:textColor="#FFFFFF"
        android:textColorHint="#000000"
        android:textSize="34sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.44"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.041" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="204dp"
        android:layout_height="43dp"
        android:text="Registration"
        android:textColor="#FFFDFD"
        android:textSize="34sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView"
        app:layout_constraintVertical_bias="0.09" />

    <EditText
        android:id="@+id/editTextRegUsername"
        android:layout_width="330dp"
        android:layout_height="53dp"
        android:layout_marginTop="48dp"
        android:background="@drawable/input_bg"
        android:drawableLeft="@drawable/ic_baseline_person_24"
        android:ems="10"
        android:inputType="textPersonName"
        android:paddingLeft="20dp"
        android:paddingTop="10dp"
        android:paddingRight="10dp"
        android:paddingBottom="10dp"
        android:text="Username"
        android:textColor="#FFFFFF"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.493"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView2" />

    <EditText
        android:id="@+id/editTextRegemail"
        android:layout_width="330dp"
        android:layout_height="53dp"
        android:layout_marginTop="28dp"
        android:background="@drawable/input_bg"
        android:drawableLeft="@drawable/ic_baseline_email_24"
        android:ems="10"
        android:inputType="textPersonName"
        android:paddingLeft="20dp"
        android:paddingTop="10dp"
        android:paddingRight="10dp"
        android:paddingBottom="10dp"
        android:text="Email"
        android:textColor="#FFFFFF"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.493"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editTextRegUsername" />

    <Button
        android:id="@+id/buttonregister"
        android:layout_width="326dp"
        android:layout_height="48dp"
        android:layout_marginTop="28dp"
        android:background="@drawable/btn_bg"
        android:text="REGISTER"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.494"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editTextRegConfirmPassword" />

    <TextView
        android:id="@+id/textViewExisting"
        android:layout_width="127dp"
        android:layout_height="28dp"
        android:paddingTop="5dp"
        android:text="Already exist user"
        android:textAlignment="center"
        android:textAllCaps="false"
        android:textColor="#F4F4F4"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/buttonregister"
        app:layout_constraintVertical_bias="0.559" />
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".LoginActivity"
    android:background="@drawable/back1">

    <EditText
        android:id="@+id/editTextLoginPassword"
        android:layout_width="330dp"
        android:layout_height="53dp"
        android:layout_marginTop="28dp"
        android:background="@drawable/input_bg"
        android:drawableLeft="@drawable/ic_baseline_security_24"
        android:ems="10"
        android:hint="Password"
        android:inputType="textPassword"
        android:paddingLeft="20dp"
        android:paddingTop="10dp"
        android:paddingRight="10dp"
        android:paddingBottom="10dp"
        android:text="Password"
        android:textColor="#FFFFFF"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.493"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editTextLoginUsername" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="227dp"
        android:layout_height="58dp"
        android:selectAllOnFocus="true"
        android:shadowColor="#000000"
        android:text="HealthCare"
        android:textAlignment="center"
        android:textAppearance="@style/TextAppearance.AppCompat.Body1"
        android:textColor="#FFFFFF"
        android:textColorHint="#000000"
        android:textSize="34sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.075"
        />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="86dp"
        android:layout_height="41dp"
        android:text="Login"
        android:textColor="#FFFDFD"
        android:textSize="34sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView"
        app:layout_constraintVertical_bias="0.11"
        />

    <EditText
        android:id="@+id/editTextLoginUsername"
        android:layout_width="330dp"
        android:layout_height="53dp"
        android:layout_marginTop="88dp"
        android:background="@drawable/input_bg"
        android:drawableLeft="@drawable/ic_baseline_person_24"
        android:ems="10"
        android:inputType="textPersonName"
        android:paddingLeft="20dp"
        android:paddingTop="10dp"
        android:paddingRight="10dp"
        android:paddingBottom="10dp"
        android:text="Username"
        android:textColor="#FFFFFF"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.493"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView2" />

    <Button
        android:id="@+id/buttonLogin"
        android:layout_width="326dp"
        android:layout_height="48dp"
        android:layout_marginTop="56dp"
        android:background="@drawable/btn_bg"
        android:text="Login"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.47"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editTextLoginPassword" />

    <TextView
        android:id="@+id/textViewNewUser"
        android:layout_width="127dp"
        android:layout_height="28dp"
        android:paddingTop="5dp"
        android:text="Register/New User"
        android:textAlignment="center"
        android:textAllCaps="false"
        android:textColor="#F4F4F4"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/buttonLogin"
        app:layout_constraintVertical_bias="0.152" />

</androidx.constraintlayout.widget.ConstraintLayout>
package com.example.healthcareproject;

import static com.example.healthcareproject.R.id.editTextRegPassword;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class RegisterActivity extends AppCompatActivity {

    EditText edusername,edpassword,edemail,edconfirm;
    Button bt;
    TextView txt;


    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        edusername = findViewById(R.id.editTextRegUsername);
        edpassword = findViewById(editTextRegPassword);
        edemail =findViewById(R.id.editTextRegemail);
        edconfirm =findViewById(R.id.editTextRegConfirmPassword);
        bt =findViewById(R.id.buttonregister);
        txt =findViewById(R.id.textViewExisting);

        txt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(RegisterActivity.this,LoginActivity.class));
            }
        });

        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String username = edusername.getText().toString();
                String password = edpassword.getText().toString();
                String confirm = edconfirm.getText().toString();
                String email = edemail.getText().toString();
                database db = new database(getApplicationContext(),"healthcareProject",null,1);

                if(username.length()==0 || password.length()==0 || email.length()==0 | confirm.length()==0){
                    Toast.makeText(getApplicationContext(), "Invalid Input", Toast.LENGTH_SHORT).show();
                }else{
                    if(password.compareTo(confirm)==0){
                        if(isValid(password)){
                            Toast.makeText(getApplicationContext(), "Registered Successfully", Toast.LENGTH_SHORT).show();
                            startActivity(new Intent(RegisterActivity.this,LoginActivity.class));
                        }else{
                            Toast.makeText(getApplicationContext(), "Password must contain at least 8 characters", Toast.LENGTH_SHORT).show();
                        }
                    }else{
                        Toast.makeText(getApplicationContext(), "Password and confirm Password didn't matched", Toast.LENGTH_SHORT).show();
                    }
                }
            }
        });
    }

    private boolean isValid(String Passwordcheck) {
            int f1=0,f2=0,f3=0;
            if(Passwordcheck.length() < 8){
                return false;
            }else{
                for(int i=0;i<Passwordcheck.length();i++){
                    if(Character.isLetter(Passwordcheck.charAt(i))){
                        f1=1;
                    }
                }
                for(int j=0;j<Passwordcheck.length();j++){
                    if(Character.isDigit(Passwordcheck.charAt(j))){
                        f2=1;
                    }
                }
                for(int k=0;k<Passwordcheck.length();k++){
                    char c =Passwordcheck.charAt(k);
                    if(c>= 33 && c<=46 || c==64){
                        f3=1;
                    }
                }
                if(f1==1 && f2==1 && f3==1){
                    return true;
                }
                return false;
            }
    }

}
package com.example.healthcareproject;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class LoginActivity extends AppCompatActivity {


    EditText edusername,edpassword;
    Button bt;
    TextView txt;
    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        edpassword =findViewById(R.id.editTextLoginPassword);
        edusername = findViewById(R.id.editTextLoginUsername);
        bt = findViewById(R.id.buttonLogin);
        txt= findViewById(R.id.textViewNewUser);

        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String username = edusername.getText().toString();
                String password = edpassword.getText().toString();
                database db = new database(getApplicationContext(),"healthcareproject",null,1);

                if(username.length()==0 || password.length()==0){
                    Toast.makeText(getApplicationContext(),"Invalid input",Toast.LENGTH_SHORT).show();
                }else{
                    if(db.login(username,password)==1) {
                        Toast.makeText(getApplicationContext(), "Login successfully", Toast.LENGTH_SHORT).show();
                    }else{
                        Toast.makeText(getApplicationContext(),"Invalid Username and password",Toast.LENGTH_SHORT).show();
                    }
                }
            }
        });

        txt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent());
            }
        });
    }
Write C programing to delete a node with a specific value from linked list.

#include <stdio.h> 
#include <stdlib.h> 
  
struct Node { 
    int data; 
    struct Node* next; 
}; 
  
void push(struct Node** head_ref, int new_data) 
{ 
    struct Node* new_node 
        = (struct Node*)malloc(sizeof(struct Node)); 
    new_node->data = new_data; 
    new_node->next = (*head_ref); 
    (*head_ref) = new_node; 
} 

void deleteNode(struct Node** head_ref, int key) 
{ 
    struct Node *temp = *head_ref, *prev; 
  
    if (temp != NULL && temp->data == key) { 
        *head_ref = temp->next;
        free(temp); 
        return; 
    } 
    
    while (temp != NULL && temp->data != key) { 
        prev = temp; 
        temp = temp->next; 
    } 
  
    if (temp == NULL) 
        return; 
  
    prev->next = temp->next; 
  
    free(temp); 
} 
 
void printList(struct Node* node) 
{ 
    while (node != NULL) { 
        printf(" %d ", node->data); 
        node = node->next; 
    } 
} 

int main() 
{ 
    /* Start with the empty list */
    struct Node* head = NULL; 
  
    push(&head, 7); 
    push(&head, 1); 
    push(&head, 3); 
    push(&head, 2); 
  
    puts("Created Linked List: "); 
    printList(head); 
    deleteNode(&head, 1); 
    puts(" \nLinked List after Deletion of 1: "); 
    printList(head); 
    return 0; 
}

//OUTPUT:

Created Linked List: 
 2  3  1  7  
Linked List after Deletion of 1: 
 2  3  7 
#include <stdio.h>
#include <stdlib.h>

struct node {
    int data;          
    struct node *next; 
}*head;

void createList(int n);
void insertNodeAtBeginning(int data);
void displayList();


int main()
{
    int n, data;

    printf("Enter the total number of nodes: ");
    scanf("%d", &n);
    createList(n);

    printf("\nData in the list \n");
    displayList();
    
    printf("\nEnter data to insert at beginning of the list: ");
    scanf("%d", &data);
    insertNodeAtBeginning(data);

    printf("\nData in the list \n");
    displayList();

    return 0;
}

void createList(int n)
{
    struct node *newNode, *temp;
    int data, i;

    head = (struct node *)malloc(sizeof(struct node));

    if(head == NULL)
    {
        printf("Unable to allocate memory.");
    }
    else
    {
        printf("Enter the data of node 1: ");
        scanf("%d", &data);

        head->data = data; 
        head->next = NULL; 

        temp = head;

        for(i=2; i<=n; i++)
        {
            newNode = (struct node *)malloc(sizeof(struct node));

            if(newNode == NULL)
            {
                printf("Unable to allocate memory.");
                break;
            }
            else
            {
                printf("Enter the data of node %d: ", i);
                scanf("%d", &data); 

                newNode->data = data;
                newNode->next = NULL; 

                temp->next = newNode;
                
                temp = temp->next; 
            }
        }
    }
}

void insertNodeAtBeginning(int data)
{
    struct node *newNode;

    newNode = (struct node*)malloc(sizeof(struct node));

    if(newNode == NULL)
    {
        printf("Unable to allocate memory.");
    }
    else
    {
        newNode->data = data; 
        newNode->next = head;

        head = newNode; 

        printf("DATA INSERTED SUCCESSFULLY\n");
    }
}
void displayList()
{
    struct node *temp;

    
    if(head == NULL)
    {
        printf("List is empty.");
    }
    else
    {
        temp = head;
        while(temp != NULL)
        {
            printf("Data = %d\n", temp->data); 
            temp = temp->next; 
        }
    }
}

//OUTPUT:

Enter the total number of nodes: 4
Enter the data of node 1: 20
Enter the data of node 2: 30
Enter the data of node 3: 40
Enter the data of node 4: 50
Data in the list 
Data = 20
Data = 30
Data = 40
Data = 50

Enter data to insert at beginning of the list: 300
DATA INSERTED SUCCESSFULLY

Data in the list 
Data = 300
Data = 20
Data = 30
Data = 40
Data = 50
//İnsertion at beginning of linklist.

struct Node
{
    int data;
    struct Node* next;
};

struct Node* head;

void insert (int x)
{
    Node* temp = (Node*)malloc(sizeof(struct Node));
    temp -> data = x;
    temp -> next = head;
    head = temp;
}

void print()
{
    struct Node* temp = head;
    printf("List is: ");
    while(temp != NULL)
    {
        printf("%d ", temp -> data);
        temp = temp -> next;
    }
    printf("\n");
}
 
int main() {
    
    head = NULL;
    printf("How many numbers? \n:");
    int n, i, x;
    scanf("%d",n);
    for(i = 0; i < n; i++)
    {
        printf("Enter the number \n");
        scanf("%d", x);
        insert(x);
        print();
    }
    return 0;
}
//CREATİON OF LİNKLİST

#include <stdio.h>
#include <stdlib.h>

typedef struct 
{
    int data;
    struct Node*next;
    
} Node;

int main() {
    
    Node* n1;
    Node* n2;
    Node* n3;
    
    n1 = (Node*)(malloc(sizeof(Node)));
    n2 = (Node*)(malloc(sizeof(Node)));
    n3 = (Node*)(malloc(sizeof(Node)));
    
    
    n1 -> data = 10;
    n2 -> data = 20;
    n3 -> data = 30;
    
    
    n1 -> next = n2;
    n2 -> next = n3;
    n3 -> next = NULL;
    
    
    Node* temp = n1;
    
    while(temp != NULL)
    {
        printf("\nData: %d , next Adress: %d", temp -> data, temp -> next);
        temp = temp -> next;
    }

    return 0;
}
https://www.facebook.com/605744985040880/posts/pfbid02RBpxb4DpuPYrm4GWgG3sNMuM5h4ohSGct1pGRrpWJ8bdMUvMiC9hwmsYZT1k3VdVl
https://www.facebook.com/605744985040880/posts/pfbid02RBpxb4DpuPYrm4GWgG3sNMuM5h4ohSGct1pGRrpWJ8bdMUvMiC9hwmsYZT1k3VdVl
Write a c program to find the second smallest element in an integer array.

#include <stdio.h>
 #include <limits.h>
 
int main() {
    
    int arr[] = {1,1,1,1,1,1};
  //int arr[] = {9,5,2,8,1};
    int size = sizeof(arr) / sizeof(arr[0]);
    int smallest = INT_MAX;
    int secondSmallest = INT_MAX;

    for (int i = 0; i < size; i++) {
        if (arr[i] < smallest) {
            secondSmallest = smallest;
            smallest = arr[i];
        } 
        else if (arr[i] < secondSmallest && arr[i] != smallest) {
            secondSmallest = arr[i];
        }
    }

    if (secondSmallest == INT_MAX) {
        printf("No second smallest element found.\n");
    } 
    else {
        printf("Second smallest element: %d\n", secondSmallest);
    }

    return 0;
}
output: No second smallest element found.
//OutPUT : Second smallest element: 2
Answer 2:

public class Student {
	
	String name;
	int age;
	boolean isJunior;
	char gender;
	
	Student()
	{
		name = "Mohamed";
		age = 23;
		isJunior = false;
		gender = 'm';
	}
	Student(String nme, int n, boolean job, char gen) 
	{
		name = nme;
		age = n;
		isJunior = job;
		gender = gen;
	}
	
	public static void main(String[] args) {
		
		Student s1 = new Student();
		Student s2 = new Student("Ayşe", 15, true, 'f');
		
		System.out.println("Name S1 = " + s1.name);
		System.out.println("Age S1 = " + s1.age);
		System.out.println("isJunior S1 = " + s1.isJunior);
		System.out.println("Gender S1 = " + s1.gender);

		System.out.println("\n\nName S2 = " + s2.name);
		System.out.println("Age S2 = " + s2.age);
		System.out.println("isJunior S2 = " + s2.isJunior);
		System.out.println("Gender S2 = " + s2.gender);
	}
}
//OUTPUT:

Name S1 = Mohamed
Age S1 = 23
isJunior S1 = false
Gender S1 = m


Name S2 = Ayşe
Age S2 = 15
isJunior S2 = true
Gender S2 = f
Question 1. Write a method that combines two given arrays and returns the resulting array back.  Complete your program with a main method.

Answer 1:

public static void main(String[] args) {
		
		
		int[] array1 = {2,4,6,8,10,12};
		int[] array2 = {1,3,5,7,9};
		int[] array3 = {20,30,40,50,60,70,80};
		
		System.out.println("array1 = " + Arrays.toString(array1));
		System.out.println("array2 = " + Arrays.toString(array2));
		System.out.println("array3 = " + Arrays.toString(array3));
		
		int [] array4 = combineArrays(array1, array2, array3);
		
		System.out.println("\nAfter Combination of Three arrays are: ");
		
		System.out.println("\narray4 = " + Arrays.toString(array4));
		
		
		sortSmallToLarge(array4);
		System.out.println();
		System.out.println("\nAfter sorting arrays from Small number to Large number.");
		
		System.out.println(Arrays.toString(array4));
		
		
		sortLargeToSmall(array4);
		System.out.println();
		System.out.println("\nAfter sorting arrays from Large number to Small number.");
		
		System.out.println(Arrays.toString(array4));


	}
	public static int[] combineArrays(int[] array1, int[] array2, int[] array3) {
		int[] array4 = new int[array1.length + array2.length + array3.length];
		for(int i=0; i<array1.length; i++) {
			array4[i] = array1[i];
		}
		for(int i=0; i<array2.length; i++) {
			array4[array1.length + i] = array2[i];
		}
		for(int i=0; i<array3.length; i++) {
			array4[array1.length + array2.length + i] = array3[i];
		}
		return array4;
	}
	
	public static void sortSmallToLarge(int [] array4) {
		for(int i =0; i< array4.length; i++) {
			for(int j=0; j<array4.length-1-i; j++) {
				if(array4[j] > array4 [j+1]) {
					int temp = array4[j];
					array4[j] = array4[j+1];
					array4[j+1] = temp;
				}
			}
		}
	}
	public static void sortLargeToSmall(int [] array4) {
		for(int i =0; i< array4.length; i++) {
			for(int j=0; j<array4.length-1-i; j++) {
				if(array4[j] < array4 [j+1]) {
					int temp = array4[j];
					array4[j] = array4[j+1];
					array4[j+1] = temp;
				}
			}
		}
	}
}
//OUTPUT: 
array1 = [2, 4, 6, 8, 10, 12]
array2 = [1, 3, 5, 7, 9]
array3 = [20, 30, 40, 50, 60, 70, 80]

After Combination of Three arrays are: 

array4 = [2, 4, 6, 8, 10, 12, 1, 3, 5, 7, 9, 20, 30, 40, 50, 60, 70, 80]


After sorting arrays from Small number to Large number.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 20, 30, 40, 50, 60, 70, 80]


After sorting arrays from Large number to Small number.
[80, 70, 60, 50, 40, 30, 20, 12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

public class Main {
    public static void main(String[] args) {
 
        String myFirstString = "Hello Test Pro Student!";
 
    }
}
public class Main {
    public static void main(String[ ] args) {

        int age = 21;

        if (age < 21) {
            throw new ArithmeticException("Sorry - We only sell to customers 21 years old and above!");
        }
        else {
            System.out.println("Order accepted!");
        }
    }
}
// Output: Order accepted!
public class Main {
    public static void main(String[ ] args) {

        int age = 19;

        if (age < 21) {
            throw new ArithmeticException("Sorry - We only sell to customers 21 years old and above!");
        }
        else {
            System.out.println("Order accepted!");
        }
    }
}
// Output: Exception in thread "main" java.lang.ArithmeticException: Sorry - We only sell to customers 21 years old and above!
//	at org.example.Main.main(Main.java:12)
class Main {
  public static void main (String[] args) {

    int c = 4;

    System.out.println (++c);
  }
}
// Output: 5
class Main {
  public static void main (String[] args) {

    int c = 4;

    System.out.println (--c);
  }
}
// Output: 3
class Main {
  public static void main (String[] args) {

    int a = 8;
    int b = 7;

    int result = a%b;

    System.out.println (result);
  }
}
// Output: 1
// Note: Output is 1 since the remainder is 1
class Main {
    public static void main(String[] args) {

       double a = 5;
       double b = 2;
      
       double result = a/b;
      
       System.out.println(result);
    }
}
// Output: 2.5
class Main {
  public static void main (String[] args) {

    int a = 8;
    int b = 7;

    int result = a*b;

    System.out.println (result);
  }
}
// Output: 56
class Main {
  public static void main (String[] args) {

    int a = 8;
    int b = 7;

    int result = a-b;

    System.out.println (result);
  }
}
// Output: 1
class Main {
  public static void main (String[] args) {
 
    int a = 8;
    int b = 7;
 
    int result = a+b;
 
    System.out.println (result);
  }
}
// Output: 15
dependencies {
    testImplementation 'org.testng:testng:7.6.1'
    implementation 'org.seleniumhq.selenium:selenium-java:4.5.0'
    testImplementation 'io.github.bonigarcia:webdrivermanager:5.3.1'
    implementation 'io.cucumber:cucumber-testng:7.9.0'
    implementation 'io.cucumber:cucumber-core:7.9.0'
    implementation 'io.cucumber:cucumber-java:7.9.0'
    implementation 'io.cucumber:gherkin:25.0.2'
}
import io.cucumber.java.en.Given;

public class StepDefinitions {
  
    @Given("I am in the Home Page")
    public void i_am_in_the_home_page() {
        driver.get("sampleHomePage")
    }
}
Scenario: Home Page Navigation

Given I am in the Home page
Feature: Login feature

Scenario: Login with valid credentials
Given I am in the Login Page
And I enter a registered email
And I enter a valid password
When I click the submit button
Then I must be logged in successfully
Then I must be logged in successfully
When I click the submit button
And I enter a registered email
And I enter a valid password
Given I am in the Login Page
<suite name="Test Pro Parallel Testing" parallel="methods" thread-count="5">
C:\Users\TestProUser> java -jar selenium-server-4.7.2.jar standalone

06:09:51.094 INFO [LocalDistributor.add] - Added node de4f0f9b-bf52-46d0-94a4-2dd3167b0e17 at http://192.168.55.100:4444. Health check every 120s
06:09:51.299 INFO [Standalone.execute] - Started Selenium Standalone 4.7.2 (revision 79f1c02ae20): http://192.168.55.100:4444
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 20), this);
 PageFactory.initElements(driver, java.lang.Class.pageObjectClass);
 @FindBy(how = How.CSS, using = "div[class='logo']")
 WebElement koelImgCssHow;

 @FindBy(how = How.XPATH, using = "//div[@class='logo']")
  WebElement koelImgXpathHow;
 @FindBy(css="div[class='logo']")
 WebElement koelImgCss;

 @FindBy(xpath="//div[@class='logo']")
 WebElement koelImgXpath;
Actions a = new Actions(driver);
 
//Right click on element
WebElement button = driver.findElement(By.xpath("locator"));
 
a.contextClick(button).perform();
Actions a = new Actions(driver);

//Double click on element
WebElement button = driver.findElement(By.xpath("locator"));

a.doubleClick(button).perform();
Actions action = new Actions(driver);

//Move over the menu options
WebElement menuOption = driver.findElement(By.xpath("locator"));
action.moveToElement(menuOption).perform();

//Displays the menu list with options, now we can click an option from the menu list
WebElement selectMenuOption = driver.findElement(By.xpath("locator2"));
action.click(selectMenuOption).perform();
@BeforeMethod
@Parameters({"BaseURL"})
public void launchBrowser(String BaseURL) {
  
  ChromeOptions options = new ChromeOptions();
  options.addArguments("--remote-allow-origins=*");

  WebDriver driver = new ChromeDriver(options);
  driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
  url = BaseURL;
  driver.get(url);
}
   @Test
    public void homepageNavigation() {
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");

        WebDriver driver = new ChromeDriver(options);
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));

        String expectedUrl = "https://qa.koel.app/";
        driver.get(expectedUrl);

        Assert.assertEquals(driver.getCurrentUrl(), expectedUrl);

        driver.quit();
    }
import java.util.HashMap;

public class Main {
    public static void main(String[] args) {

        // {key:value, key2:value2 ...}

        // France: Paris
        // Italy: Rome
        // Norway: Oslo
        // US: Washington DC

        HashMap<String, String> countryCapitals = new HashMap<>();
        countryCapitals.put("France","Paris");
        countryCapitals.put("Italy", "Rome");
        countryCapitals.put("Norway", "Oslo");
        countryCapitals.put("US", "Washington DC");
        countryCapitals.remove("Italy");

        HashMap<Integer, String> capitals = new HashMap<>();
        capitals.put(1,"Paris");
        capitals.put(2, "Rome");
        capitals.put(3, "Oslo");
        capitals.put(4, "Washington DC");

        System.out.println(capitals.get(3));
    }
}
// Output: Oslo
import java.util.HashMap;

public class Main {
    public static void main(String[] args) {

        HashMap<String, String> countryCapitals = new HashMap<>();
        countryCapitals.put("France","Paris");
        countryCapitals.put("Italy", "Rome");
        countryCapitals.put("Norway", "Oslo");
        countryCapitals.put("US", "Washington DC");

        System.out.println( countryCapitals.values());
    }
}
// Output: [Oslo, Rome, Paris, Washington DC]
import java.util.HashMap;

public class Main {
    public static void main(String[] args) {

        HashMap<String, String> countryCapitals = new HashMap<>();
        countryCapitals.put("France","Paris");
        countryCapitals.put("Italy", "Rome");
        countryCapitals.put("Norway", "Oslo");
        countryCapitals.put("US", "Washington DC");

        System.out.println( countryCapitals.keySet());
    }
}
// Output: [Norway, Italy, France, US]
import java.util.HashMap;

public class Main {
    public static void main(String[] args) {

        HashMap<String, String> countryCapitals = new HashMap<>();
        countryCapitals.put("France","Paris");
        countryCapitals.put("Italy", "Rome");
        countryCapitals.put("Norway", "Oslo");
        countryCapitals.put("US", "Washington DC");

        System.out.println( countryCapitals.size());
    }
}
// Output: 4
import java.util.HashMap;

public class Main {
    public static void main(String[] args) {

        // {key:value, key2:value2 ...}

        // France: Paris
        // Italy: Rome
        // Norway: Oslo
        // US: Washington DC

        HashMap<String, String> countryCapitals = new HashMap<>();
        countryCapitals.put("France","Paris");
        countryCapitals.put("Italy", "Rome");
        countryCapitals.put("Norway", "Oslo");
        countryCapitals.put("US", "Washington DC");
        countryCapitals.remove("Italy");

        System.out.println(countryCapitals);
    }
}
// Output: {Norway=Oslo, France=Paris, US=Washington DC}
import java.util.HashMap;

public class Main {
    public static void main(String[] args) {

        HashMap<String, String> countryCapitals = new HashMap<>();
        countryCapitals.put("France","Paris");
        countryCapitals.put("Italy", "Rome");
        countryCapitals.put("Norway", "Oslo");
        countryCapitals.put("US", "Washington DC");

        System.out.println( countryCapitals.get("Italy"));
    }
}
// Output: Rome
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) {

        Set<Integer> set1 = new HashSet<>();
        set1.add(1);
        set1.add(3);
        set1.add(2);
        set1.add(4);
        set1.add(8);
        set1.add(9);
        set1.add(0);

        Set<Integer> set2 = new HashSet<>();
        set2.add(1);
        set2.add(3);
        set2.add(7);
        set2.add(5);
        set2.add(4);
        set2.add(0);
        set2.add(7);
        set2.add(5);

        // difference
        Set<Integer> setDifference = new HashSet<>(set1);
        setDifference.removeAll(set2);
        System.out.println(setDifference);
    }
}
// Output: [2, 8, 9]
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) {

        Set<Integer> set1 = new HashSet<>();
        set1.add(1);
        set1.add(3);
        set1.add(2);
        set1.add(4);
        set1.add(8);
        set1.add(9);
        set1.add(0);

        Set<Integer> set2 = new HashSet<>();
        set2.add(1);
        set2.add(3);
        set2.add(7);
        set2.add(5);
        set2.add(4);
        set2.add(0);
        set2.add(7);
        set2.add(5);

        // intersection
        Set<Integer> setIntersection = new HashSet<>(set1);
        setIntersection.retainAll(set2);
        System.out.println(setIntersection);
    }
}
// Output: [0, 1, 3, 4]
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) {

        Set<Integer> set1 = new HashSet<>();
        set1.add(1);
        set1.add(3);
        set1.add(2);
        set1.add(4);
        set1.add(8);
        set1.add(9);
        set1.add(0);

        Set<Integer> set2 = new HashSet<>();
        set2.add(1);
        set2.add(3);
        set2.add(7);
        set2.add(5);
        set2.add(4);
        set2.add(0);
        set2.add(7);
        set2.add(5);

        // Union
        Set<Integer> set3 = new HashSet<>(set1);
        set3.addAll(set2);
        System.out.println(set3);
    }
}
// Output: [0, 1, 2, 3, 4, 5, 7, 8, 9]
import java.util.Set;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {

        Set<String> uniqueKoelPages = new TreeSet<>();

        uniqueKoelPages.add("LoginPage");
        uniqueKoelPages.add("HomePage");
        uniqueKoelPages.add("HomePage");
        uniqueKoelPages.add("ProfilePage");
        uniqueKoelPages.add("AProfilePage");

        System.out.println(uniqueKoelPages);
    }
}
// Output: [AProfilePage, HomePage, LoginPage, ProfilePage]
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) {

        Set<String> uniqueKoelPages = new HashSet<>();

        uniqueKoelPages.add("LoginPage");
        uniqueKoelPages.add("HomePage");
        uniqueKoelPages.add("HomePage");
        uniqueKoelPages.add("ProfilePage");
        uniqueKoelPages.add("AProfilePage");

        System.out.println(uniqueKoelPages);
    }
}
// Output: [HomePage, ProfilePage, AProfilePage, LoginPage]
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void main(String[] args) {

        List<String> koelPages = new ArrayList<>();

        koelPages.add("LoginPage");
        koelPages.set(0, "RegistrationPage");
        koelPages.add("HomePage");
        koelPages.add("ProfilePage");
        koelPages.add("APage");
        koelPages.add("ZPage");
        Collections.sort(koelPages);
        Collections.reverse(koelPages);

        for (String i : koelPages) {
            System.out.println(i);
        }
    }
}
/* Output:
ZPage
RegistrationPage
ProfilePage
HomePage
APage
*/
List <String> koelPages = new ArrayList<>();

for(String i: koelPages)
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {

        List<String> koelPages = new ArrayList<>();

        koelPages.add("LoginPage");
        koelPages.add("HomePage");
        koelPages.add("ProfilePage");
        koelPages.add("APage");
        koelPages.add("ZPage");

        Collections.sort(koelPages);
        Collections.reverse(koelPages);
        System.out.println(koelPages);
    }
}
// Output: [ZPage, ProfilePage, LoginPage, HomePage, APage]
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {

        List<String> koelPages = new ArrayList<>();

        koelPages.add("LoginPage");
        koelPages.add("HomePage");
        koelPages.add("ProfilePage");
        koelPages.add("APage");
        koelPages.add("ZPage");

        Collections.sort(koelPages);
        System.out.println(koelPages);
    }
}
// Output: [APage, HomePage, LoginPage, ProfilePage, ZPage]
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {

        List<String> koelPages = new ArrayList<>();

        koelPages.add("RegistrationPage");
        koelPages.add("LoginPage");
        koelPages.add("HomePage");

        System.out.println(koelPages.size());
    }
}
// Output: 3
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {

        List<String> koelPages = new ArrayList<>();

        koelPages.add("RegistrationPage");
        koelPages.add("LoginPage");
        koelPages.add("HomePage");
        koelPages.remove(0);

        System.out.println(koelPages);
    }
}
// Output: [LoginPage, HomePage]
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {

        List<String> koelPages = new ArrayList<>();

        koelPages.add("RegistrationPage");
        koelPages.add("LoginPage");
        koelPages.add("HomePage");
        koelPages.set(0,"ProfilePage");

        System.out.println(koelPages);
    }
}
// Output: [ProfilePage, LoginPage, HomePage]
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {

        List<String> koelPages = new ArrayList<>();

        koelPages.add("RegistrationPage");
        koelPages.add("LoginPage");
        koelPages.add("HomePage");

        System.out.println(koelPages.get(0));
    }
}
// Output: RegistrationPage
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {

        List<String> koelPages = new ArrayList<>();

        koelPages.add("RegistrationPage");
        koelPages.add("LoginPage");
        koelPages.add("HomePage");

        System.out.println(koelPages);
    }
}
// Output: [RegistrationPage, LoginPage, HomePage]
import java.util.Arrays;

class Main {
    public static void main(String[] args) {

        int [] arr1 = {54, 44, 39, 10, 12, 101};

        Arrays.sort (arr1);

        System.out.println (Arrays.toString(arr1));
    }
}
// Output: [10, 12, 39, 44, 54, 101]
class Main {
    public static void main(String[] args) {

        int[] arr1 = {54, 44, 39, 10, 12, 101};
        for (int i=0; i<arr1.length; i++) {
            if (arr1[i] == 44) {
                System.out.println ("Array has a value of 44 at index " + i);
            }
        }
    }
}
// Output: Array has a value of 44 at index 1
import java.util.Arrays;

class Main {
    public static void main(String[] args) {

        int [] arr1 = new int[10];

        for (int i = 0; i < 10; i++) {

            arr1 [i] = i;
        }
        System.out.println(Arrays.toString(arr1));
    }
}
// Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
class Main {
    public static void main(String[] args) {

        int[] arr2 = new int[10];

        arr2[0] = 1;

        System.out.println(arr2[0]);

    }
}
// Output: 1
class Main {
    public static void main(String[] args) {

        int [] arr1 = {1,2,3,4,5,6,7,8,9,10};

        arr1[1] = 22;

        System.out.println (arr1[1]);
    }
}
// Output: 22
class Main {
    public static void main(String[] args) {

        int [] arr1 = {1,2,3,4,5,6,7,8,9,10};

        System.out.println (arr1[3]);
    }
}
// Output: 4
public class Wrangler extends Car {
 
    boolean carDoors = true;
 
    public void takeOffDoors() {
        carDoors = false;
        System.out.println("Doors are taken off");
    }
 
    public void putBackDoors() {
        carDoors = true;
        System.out.println("Doors are back");
 
    }
    public String returnCarModel() {
        return "Car model is Wrangler";
    }
}
public class ModelX extends Car {

    boolean autoPilot = false;

    public void switchAutopilotOn() {
        autoPilot = true;
        System.out.println("Autopilot is switched on");
    }

    public void switchAutopilotOff() {
        autoPilot = false;
        System.out.println("Autopilot is switched off");
    }

    public String returnCarModel() {
        return "Car model is ModelX";
    }
}
public class Car {
 
    private int odometer = 0;
    private int productionYear = 0;
 
    public void setProductionYear(int year){
        productionYear = year;
    }
    
    public int getProductionYear (){
        return  productionYear;
    }
 
    public void drive( int miles) {
        System.out.println("Car drove " + miles + " miles");
        odometer = odometer + miles;
    }
 
    public String returnCarModel() {
        return "Car model is unknown";
    }
}
public class Main {
    public static void main(String[] args) {
 
        Wrangler myWranglerCar = new Wrangler();
        myWranglerCar.drive( 100);
        myWranglerCar.takeOffDoors();
        System.out.println(myWranglerCar.returnCarModel());
        myWranglerCar.setProductionYear(2022);
        System.out.println(myWranglerCar.getProductionYear());
 
        ModelX myModelXCar = new ModelX();
        myModelXCar.drive( 90);
        myModelXCar.switchAutopilotOn();
        System.out.println(myModelXCar.returnCarModel());
        myModelXCar.setProductionYear(2021);
        System.out.println(myModelXCar.getProductionYear());
 
        Car myCar = new Car();
        myCar.drive(50);
        System.out.println(myCar.returnCarModel());
    }
}
/* Output:
Car drove 100 miles
Doors are taken off
Car model is Wrangler
2022
Car drove 90 miles
Autopilot is switched on
Car model is ModelX
2021
Car drove 50 miles
Car model is unknown
*/
public class Wrangler extends Car {

    boolean carDoors = true;

    public void takeOffDoors() {
        carDoors = false;
        System.out.println("Doors are taken off");
    }

    public void putBackDoors() {
        carDoors = true;
        System.out.println("Doors are back");

    }

    public String returnCarModel() {
        return "Car model is Wrangler";
    }
}
public class Main {
    public static void main(String[] args) {

        Wrangler myWranglerCar = new Wrangler();
        myWranglerCar.drive( 100);
        System.out.println("Wrangler odometer displays " +myWranglerCar.odometer+ " miles");
        myWranglerCar.takeOffDoors();
        System.out.println(myWranglerCar.returnCarModel());

        ModelX myModelXCar = new ModelX();
        myModelXCar.drive( 90);
        System.out.println("ModelX odometer displays " +myModelXCar.odometer+ " miles");
        myModelXCar.switchAutopilotOn();
        System.out.println(myModelXCar.returnCarModel());

        Car myCar = new Car();
        myCar.drive(50);
        System.out.println(myCar.returnCarModel());
    }
}
/* Output:
Car drove 100 miles
Wrangler odometer displays 100 miles
Doors are taken off
Car model is Wrangler
Car drove 90 miles
ModelX odometer displays 90 miles
Autopilot is switched on
Car model is ModelX
Car drove 50 miles
Car model is unknown
*/
public class ModelX extends Car {

    boolean autoPilot = false;

    public void switchAutopilotOn() {
        autoPilot = true;
        System.out.println("Autopilot is switched on");
    }

    public void switchAutopilotOff() {
        autoPilot = false;
        System.out.println("Autopilot is switched off");
    }

    public String returnCarModel() {
        return "Car model is ModelX";
    }
}
public class Car {

    int odometer = 0;
    
    public void drive( int miles) {
        System.out.println("Car drove " + miles + " miles");
        odometer = odometer + miles;
    }

    public String returnCarModel() {
        return "Car model is unknown";
    }
}
public class Main {
    public static void main(String[] args) {

        Wrangler myWranglerCar = new Wrangler();
        myWranglerCar.drive( 100);
        System.out.println("Wrangler odometer displays " +myWranglerCar.odometer+ " miles");
        myWranglerCar.takeOffDoors();
        ModelX myModelXCar = new ModelX();
        myModelXCar.drive( 90);
        System.out.println("ModelX odometer displays " +myModelXCar.odometer+ " miles");
        myModelXCar.switchAutopilotOn();

        Car myCar = new Car();
        myCar.drive(50);
    }
}
/* Output:
Car drove 100 miles
Wrangler odometer displays 100 miles
Doors are taken off
Car drove 90 miles
ModelX odometer displays 90 miles
Autopilot is switched on
Car drove 50 miles
*/
public class Wrangler extends Car {
    
    boolean carDoors = true;
    
    public void takeOffDoors() {
        carDoors = false;
        System.out.println("Doors are taken off");
    }
    
    public void putBackDoors() {
        carDoors = true;
        System.out.println("Doors are back");
    }
}
public class ModelX extends Car {
 
    boolean autoPilot = false;
 
    public void switchAutopilotOn() {
        autoPilot = true;
        System.out.println("Autopilot is switched on");
    }
    
    public void switchAutopilotOff() {
        autoPilot = false;
        System.out.println("Autopilot is switched off");
    }
}
public class Car {
 
    int odometer = 0;
    
    public void drive( int miles) {
        System.out.println("Car drove " + miles + " miles");
        odometer = odometer + miles;
    }
}
public class Main {
    public static void main(String[] args) {

        Cars azatCar = new Cars("Mazda", "blue",2005);
        azatCar.brand = "Mazda" ;
        azatCar.year = 2005 ;
        azatCar.color = "blue" ;

        Cars someOtherCar = new Cars ("BMW", "black") ;
        someOtherCar.color = "black" ;
        someOtherCar.year = 2020 ;
        someOtherCar.brand = "BMW" ;

        System.out.println(someOtherCar.brand);
        azatCar.accelerate() ;
        azatCar.headlightsOn() ;
        azatCar.headlightsOff() ;
        System.out.println ("odometer is equal to " + azatCar.return0dometer(100000) + " miles");
    }
}
/* Output:
BMW
Car is accelerating
Car's headlights are on
Car's headlights are off
odometer is equal to 100000 miles
*/
public class Cars {
  
    String brand;
    String color;
    int year;
  
    public Cars (String carBrand, String carColor, int carYear) {
        brand = carBrand;
        color = carColor;
        year = carYear;
    }
  
    public Cars (String carBrand, String carColor) {
        brand = carBrand;
        color = carColor;
    }
  
    public void accelerate() {
        System.out.println("Car is accelerating");
    }
  
    public void headlightsOn() {
        System.out.println("Car's headlights are on");
    }
  
    public void headlightsOff() {
        System.out.println("Car's headlights are off");
    }
  
    public int return0dometer(int odometerValue) {
        return odometerValue;
    }
}
public class Cars {
  
    public void accelerate() {
        System.out.println("car is accelerating");
    }
    public void headlightsOn() {
        System.out.println("car's headlights are on");
    }
    public void headlightsOff() {
        System.out.println("car's headlights are off");
    }
    public int return0dometer(int odometerValue) {
        return 10000;
    }
}
//1. Write a program that reads an integer between 1 and 9 and displays the roman version (I, II, : : :, IX) of that integer.

Answer 1:

public static void main(String[] args) {
		
		Scanner input = new Scanner(System.in);
		System.out.println("Enter Number between 1 _ 9: ");
		int number = input.nextInt();
		
		if(number==1) {
			System.out.println("Roman Version of " + number + " is I.");
		}
		else if (number==2) {
			System.out.println("Roman Version of " + number + " is II."); }
		else if (number==3) {
			System.out.println("Roman Version of " + number + "  is III."); }
		else if (number==4) {
			System.out.println("Roman Version of " + number + "  is IV."); }
		else if (number==5) {
			System.out.println("Roman Version of " + number + "  is V. "); }
		else if (number==6) {
			System.out.println("Roman Version of " + number + " is VI."); }
		else if (number==7) {
			System.out.println("Roman Version of " + number + "  is VII."); }
		else if (number==8) {
			System.out.println("Roman Version of " + number + "  is VIII."); }
		else if (number==9) {
			System.out.println("Roman Version of " + number + "  is IX."); }
		else
			System.out.println("valid input.");
	}
}

Q 2: Write a program which displays a menu of a burger house, asks the choice of the user and displays the cost. In the implementation use switch-case.
  
  Answer 2:
  
  Scanner input = new Scanner(System.in);
		System.out.println("Menu: ");
		System.out.println("Enter C for Cheeseburger: ");
		System.out.println("Enter H for Hot dog: ");
		System.out.println("Enter L for Lemonade: ");
		System.out.println("Enter T for Iced Tea: ");
		
		System.out.println("Enter Your Choice: ");
		String choice = input.nextLine();
		
		
		switch(choice) {
			case "c": System.out.println("Price of Chesseburger is $7.49."); break;
			case "h": System.out.println("Price of Hot dog is $6.99."); break;
			case "l": System.out.println("Price of Lemonade is $2.50."); break;
			case "t": System.out.println("Price of Iced Tea is $2.75."); break;
			
			default: System.out.println("Unrecognized menu item.");
		}
	}
}

Q 3: Write a program that generates 50 random integers between 1-6 and counts the occurrence of number 4. In the implementation use while loop.
 
 Answer 3:
 int count = 0, freq4 = 0;
		while(count < 50) {
			
			int num = (int) (Math.random() * 6 +1);
			if(num==4)
				freq4 = freq4 + 1;
			count = count + 1;
		}
		System.out.println("Number 4: " + freq4 + " times generated.");
	}
}

Q 4: Write a program that prompts the user to enter the number of students and each student’s score.  Then your program displays the class average and the highest score. In the implementation use for loop.
 
Answer 4:

		Scanner input = new Scanner(System.in);
		System.out.println("Enter number of students:");
		int stuNo = input.nextInt();
		
		int i =0;
		int sum = 0; 
		int max = 0;
		for( i =0; i<stuNo; i++) {
			System.out.println("Enter the Grade of the student: " + (i+1));
			int grade = input.nextInt();
			sum = sum + grade;
			if(grade>max)
				max =grade;
		}
		double avg = (double)sum /stuNo;
		System.out.println("Class average " + avg + " & maximum grade is " + max + " at student " + i);
	}
}   //OUTPUT: 
Enter number of students:
4
Enter the Grade of the student: 1
50
Enter the Grade of the student: 2
60
Enter the Grade of the student: 3
80
Enter the Grade of the student: 4
77
Class average 66.75 & maximum grade is 80at student 4


Q 5: Write a method named maxThreeints that takes three integers as arguments and returns the the value of the largest one.

public static int maxThreeints(int a, int b, int c)
// this method calculates and returns the max value

Complete the program with main method, which asks the user to enter three numbers , invokes maxThreeints method and displays the result.
 Answer 5:
 Scanner input = new Scanner(System.in);
		System.out.println("Enter Three Numbers:");
		System.out.println("Enter Number 1: ");
		int a = input.nextInt();
		System.out.println("Enter Number 2: ");
		int b = input.nextInt();
		System.out.println("Enter Number 3: ");
		int c = input.nextInt();
		
		int max = maxThreeints(a,b,c);
		System.out.println("The Largest value is " + max);
		
	}
	public static int maxThreeints(int a, int b, int c) {
		
		if(a >= b && a >= c)
			return a;
		else if(b >= a && b >= c)
			return b;
		else 
			return c;
	}
}
//OUTPUT:
Enter Three Numbers:
Enter Number 1: 
33
Enter Number 2: 
44
Enter Number 3: 
55
The Largest value is 55
    public class Main {
        public static void main (String[] args) {

            Cars azatFirstCar = new Cars();
            azatFirstCar.brand = "Mazda" ;
            azatFirstCar.year = 2005 ;
            azatFirstCar.color = "blue" ;

            Cars azatSecondCar = new Cars () ;
            azatSecondCar.color = "black" ;
            azatSecondCar.year = 2020 ;
            azatSecondCar.brand = "BMW" ;

            System.out.println(azatFirstCar.brand);
            System.out.println(azatSecondCar.brand);
        }
    }
/* Output:
Mazda
BMW
*/
public class Cars {

    String brand;

    String color;

    int year;

}
import java.util.Scanner;  // Import the Scanner class

public class Main {
    public static void main(String[] args) {

        Scanner userInput = new Scanner(System.in);  // Create a Scanner object
        System.out.println("Enter your zip code:");

        int zipCode = userInput.nextInt();  // Read user input
        System.out.println("Zip code: " + zipCode);  // Output user input
    }
}
/* Output:
Enter your zip code:
90232
Zip code: 90232
*/
import java.util.Scanner;  // Import the Scanner class

public class Main {
    public static void main(String[] args) {
      
        Scanner userInput = new Scanner(System.in);  // Create a Scanner object
        System.out.println("Enter email:");

        String emailAddress = userInput.nextLine();  // Read user input
        System.out.println("Email is: " + emailAddress);  // Output user input
    }
}
/* Output:
Enter email:
student@testpro.io
Email is: student@testpro.io
*/
import java.util.Scanner;  // Import the Scanner class

public class Main {
 
        public static void main(String[] args) {
            Scanner userInput = new Scanner(System.in);  // Create a Scanner object
        }
    }
public class Main {
    public static void main(String[ ] args) {

        try {

            int firstNumber = 5;
            int secondNumber = 0;
            int quotient = firstNumber / secondNumber;

            System.out.println(quotient); // error!
        }

        catch (Exception e){
            System.out.println("We can't divide a number by 0!");
        }

        finally {
            System.out.println("Our 'try catch' example is finished.");
        }
    }
}
/* Output:
We can't divide a number by 0!
Our 'try catch' example is finished.
*/
public class Main {
    public static void main(String[ ] args) {
        
        try {
            
            int firstNumber = 5;
            int secondNumber = 0;
            int quotient = firstNumber / secondNumber;
            System.out.println(quotient); // error!
        }
        
    catch (Exception e){
            System.out.println("We can't divide a number by 0!");
        }
    }
}
// Output: We can't divide a number by 0!
public class Main {
    public static void main(String[ ] args) {

        int firstNumber = 5;
        int secondNumber = 0;

        int quotient = firstNumber / secondNumber;

        System.out.println(quotient); // error!
    }
}
/* Output:
Exception in thread "main" java.lang.ArithmeticException: / by zero
	at org.example.Main.main(Main.java:8)
*/
try {
  //  Block of code to run
}
catch(Exception e) {
  //  Block of code to handle errors
}
public class Main {
    public static void main(String[] args) {

        for (int i = 0; i < 10; i++) {
            if (i == 4) {
                continue;
            }
            System.out.println(i);
        }
    }
}
/* Output:
0
1
2
3
5
6
7
8
9
*/
public class Main {
    public static void main(String[] args) {

        for (int i = 0; i < 10; i++) {
            if (i == 4) {
                break;
            }
            System.out.println(i);
        }
    }
}
/* Output:
0
1
2
3
*/
public class Main {
        public static void main(String[] args) {

            int weeks = 2;
            int weekDays = 5;

            // outer loop prints weeks
            for (int i = 1; i <= weeks; ++i) {
                System.out.println("Week: " + i);

                // inner loop prints weekdays
                for (int j = 1; j <= weekDays; ++j) {
                    System.out.println("  Day: " + j);
                }
            }
        }
    }
/* Output:
Week: 1
  Day: 1
  Day: 2
  Day: 3
  Day: 4
  Day: 5
Week: 2
  Day: 1
  Day: 2
  Day: 3
  Day: 4
  Day: 5
*/
public class Main {
    public static void main(String[] args) {

        // outer loop
        for (int i = 1; i <= 5; ++i) {
            // code to be executed

            // inner loop
            for (int j = 1; j <= 2; ++j) {
                // code to be executed

            }
        }
    }
}
package org.example;
public class Main {
    public static void main(String[] args) {

        for (int i = 0; i < 5; i++) {

            if (i == 3) {
                System.out.println("The value of i is " +i );
            }

        }
    }
}
// Output: The value of i is 3
public class Main {
    public static void main(String[] args) {

        for (int i = 0; i < 5; i++) {

            System.out.println("We love Java!");

        }
    }
}
/* Output:
We love Java!
We love Java!
We love Java!
We love Java!
We love Java!
*/
public class Main {
    public static void main(String[] args) {
      
        int i = 0;
        do {
            System.out.println("int i is equal to " +i);
            i++;
        }
        while (i < 5);
    }
}
/* Output:
int i is equal to 0
int i is equal to 1
int i is equal to 2
int i is equal to 3
int i is equal to 4
*/
public class Main {
    public static void main(String[] args) {

        int i = 0;
        while (i < 11) {
            System.out.println("int i is equal to " + i);
            i++;
        }
    }
}
/* Output: 
int i is equal to 0
int i is equal to 1
int i is equal to 2
int i is equal to 3
int i is equal to 4
int i is equal to 5
int i is equal to 6
int i is equal to 7
int i is equal to 8
int i is equal to 9
int i is equal to 10
*/
public class Main {
    public static void main(String[] args) {

        String browserType = "chrome";

        // Switch-case statement to select a browser
        switch (browserType) {
            case "chrome":
                System.out.println("Selected browser: Chrome");
                break;
            case "firefox":
                System.out.println("Selected browser: Firefox");
                break;
            case "ie":
                System.out.println("Selected browser: Internet Explorer");
                break;
            default:
                System.out.println("Unsupported browser type: " + browserType);
        }
    }
}
// Output: Selected browser: Chrome
public class Main {
    public static void main(String[] args) {
      
        boolean enrolledInAutomationClass = true; 
        boolean notEnrolledInAutomationClass = !enrolledInAutomationClass;

        System.out.println("Is the student enrolled in the automation class? " + notEnrolledInAutomationClass);
    }
}
// Output: Is the student enrolled in the automation class? false
public class Main {
    public static void main(String[] args) {

        boolean hasAccessCard = true;
        boolean hasSecurityClearance = false;

        boolean canEnterRestrictedArea = hasAccessCard || hasSecurityClearance;

        System.out.println("Can the user enter the restricted area? " + canEnterRestrictedArea);
    }
}
// Output: Can the user enter the restricted area? true
public class Main {
    public static void main(String[] args) {

        int a = 5;
        int b = 7;

        boolean notEqual = a != b;
        System.out.println("a != b is " + notEqual);
    }
}
// Output: a != b is true
public class Main {
    public static void main(String[] args) {

        String username = "admin";
        String password = "password";
        boolean isLoginSuccessful = username.equals("admin") && password.equals("password");

        System.out.println("Login successful: " + isLoginSuccessful);
    }
}
// Output: Login successful: true
public class Main {
    public static void main(String[] args) {

        int a = 5;
        int b = 5;

        boolean equalTo = a == b;
        System.out.println("a == b is " + equalTo);
    }
}
// Output: a == b is true
public class Main {
    public static void main(String[] args) {

        int a = 20;
        int b = 20;
      
        boolean greaterThanOrEqual = a >= b;
        System.out.println("a >= b is " + greaterThanOrEqual);
    }
}
// Output: a >= b is true
public class Main {
    public static void main(String[] args) {

        int a = 15;
        int b = 12;

        boolean greaterThan = a > b;
        System.out.println("a > b is " + greaterThan);
    }
}
// Output: a > b is true
public class Main {
    public static void main(String[] args) {
      
        int a = 10;
        int b = 10;
      
        boolean lessThanOrEqual = a <= b;
        System.out.println("a <= b is " + lessThanOrEqual);
    }
}
// Output: a <= b is true
public class Main {
    public static void main(String[] args) {

        int a = 5;
        int b = 10;

        boolean lessThan = a < b;
        System.out.println("a < b is " + lessThan);
    }
}
// Output: a < b is true
public class Main {
    public static void main(String[] args) {

     	String myFirstString = "Hello Test Pro Student!";
     
        System.out.println(myFirstString.toLowerCase());
    }
}
// Output: hello test pro student!
public class Main {
    public static void main(String[] args) {
 
     String myFirstString = "Hello Test Pro Student!";
 
        System.out.println(myFirstString.contains("Test Pro1"));
    }
}
// Output: false
public class Main {
    public static void main(String[] args) {
 
        String myFirstString = "Hello Test Pro Student!";
 
        System.out.println(myFirstString.contains("Test Pro"));
    }
}
// Output: true
public class Main {
    public static void main(String[] args) {

        String myFirstString = "Hello Test Pro Student!";

        System.out.println(myFirstString);
    }
}
// Output: Hello Test Pro Student!
public class Main {
    public static void main(String[] args) {
 
        String testpro1 = "TestPro";
        String testpro2 = "TestPro";
 
        System.out.println(testpro1.equals(testpro2));
    }
}
// Output: true
public class Main {
    public static void main(String[] args) {

        int a = 7;
        int b = 7;

        System.out.println(a == b);
    }
}
// Output: true
Write a method that takes 2 integers as input parameters, computes and returns their greatest common divisor (GCD).
The greatest common divisor of a set of whole numbers is the largest integer which divides them all.
Example: The greatest common divisor of 12 and 15. 
Divisors of 12: 1, 2, 3, 4, 6, 12
Divisors of 15: 1, 3, 5, 15
Common divisors: 1, 3
Greatest common divisor is 3
gcd(12,15)=3



public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		System.out.println("Enter first integer:");
		int n1 = scanner.nextInt();
		
		System.out.println("Enter secon d integer:");
		int n2 = scanner.nextInt();
		
		System.out.println("The greatest common divisor for " + n1 + " and " + n2 + " is " + gcd(n1,n2));
	}
	
	public static int gcd (int n1, int n2) {
		int gcd = 1;
		int k = 1;
		while(k <= n1 && k <= n2) {
			if(n1 % k ==0 && n2 % k ==0)
				gcd = k;
			k++;
		}
		return gcd;
	}
	
}
Write a program that generates 60 random integers in interval [0,100]. Your program computes the average of the numbers that are divisible by 3.

public static void main(String[] args) {
		
		int sum=0, count=0;
		
		 for(int i=1; i<=60; i++) {
			 
	     int num = (int) (Math.random()*101);      
		  
	     if(num%3==0) {
	       sum = sum+num; 
	       count = count+1;
	     }
		}
		 double avg=(double)sum/count;
		 System.out.println("Average: "+ avg);	
	 }
}

Scanner input = new Scanner(System.in);
		System.out.println("Enter Your Choice:");
		int choice = input.nextInt();
		
		switch(choice) {
		
		   case 1: System.out.println("Günaydin"); break;
		   case 2: System.out.println("Good morning"); break;
		   case 3: System.out.println("Bonjour"); break;
		   case 4: System.out.println("Guuten Morgen"); break;
		   
		   default:System.out.println("invalid input");
		}
import java.util.Scanner;

public class example {

	public static void main(String[] args) {
		
		int number1 = (int) (Math.random() * 10);
		int number2 = (int) (Math.random() * 10);
		
		System.out.println("What is " +number1 + " * " + number2 + "?");
		Scanner scanner = new Scanner(System.in);
		int answer = scanner.nextInt();
		
		if(number1 * number2 ==answer)
			System.out.println("You are correct");
		else
			System.out.println("your answer is Wrong\n" +number1 + " * " + number2 + " should be " + (number1 * number2));
		
	}

}