Snippets Collections
// Function.php
add_action( 'woocommerce_product_options_pricing', 'add_international_to_products' );      
function add_international_to_products() {          
    woocommerce_wp_text_input( array( 
        'id' => 'international_price', 
        'class' => 'short wc_input_price', 
        'label' => __( 'International Price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')',
        'data_type' => 'price', 
    ));      
}

add_action( 'save_post_product', 'save_international' );  
function save_international( $product_id ) {
    global $typenow;
    if ( 'product' === $typenow ) {
        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
        if ( isset( $_POST['international_price'] ) ) {
            update_post_meta( $product_id, 'international_price', $_POST['international_price'] );
        }
    }
}
// Display Code hook throw
add_action( 'woocommerce_single_product_summary', 'display_international', 9 );  
function display_international() {
    global $product;
    if ( $product->get_type() <> 'variable' && $rrp = get_post_meta( $product->get_id(), 'international_price', true ) ) {
        echo '<div class="woocommerce_international_price">';
		echo '<span>' . wc_price( $rrp ) . '</span>';
        _e( '<p>for International Customer</p> ', 'woocommerce' );       
        echo '</div>';
    }
}

function ThemeSelect() {
  const [theme, setTheme] = React.useState("day");

  function handleChange(e) {
    setTheme(e.target.value);
  }

  return (
    <select onChange={handleChange} className={theme}>
      <option value="day">Day</option>
      <option value="night">Night</option>
    </select>
  );
} 
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");
    }  
    }
    
}
extends CharacterBody2D

const SPEED = 180
const JUMPFORCE = -950
const GRAVITY = 40

func _physics_process(delta):
	if Input.is_action_pressed("right"):
		velocity.x = SPEED
	if Input.is_action_pressed("left"):
		velocity.x = -SPEED
	if Input.is_action_just_pressed("jump") and is_on_floor():
		velocity.y = JUMPFORCE
	
	
	velocity.y += GRAVITY
	move_and_slide()
	
	velocity.x = lerp(velocity.x, 0.0, 0.1)
Clear-Site-Data: "cache", "cookies", "storage"
//Contact A Start Date
Iif(Month(@mailDate) in(01,02,03), ToDate(ToString(Month(SubMonths(@mailDate,3))) + '/01' + '/' + ToString(Year(SubYears(@mailDate,1)))),ToDate(ToString(Month(SubMonths(@mailDate,3))) + '/01' + '/' + ToString(Year(GetDate()))))
//Contact B Start Date
Iif(Month(@mailDate) in(01,02,03,04,05,06), ToDate(ToString(Month(SubMonths(@mailDate,6))) + '/01' + '/' + ToString(Year(SubYears(@mailDate,1)))),ToDate(ToString(Month(SubMonths(@mailDate,6))) + '/01' + '/' + ToString(Year(@mailDate))))
//Contact C Start Date
Iif(Month(@mailDate) in(01,02,03,04,05,06,07,08,09), ToDate(ToString(Month(SubMonths(@mailDate,9))) + '/01' + '/' + ToString(Year(SubYears(@mailDate,1)))),ToDate(ToString(Month(SubMonths(@mailDate,9))) + '/01' + '/' + ToString(Year(@mailDate))))
if (instance.vars.index == 2) {
    instance.vars.index = 0} else {
    instance.vars.index +=1
   }
    
logInfo ("Counter " + instance.vars.index); 
ToInteger($(instance/vars/@index))
instance.vars.offer1SubjectLine = "<% var firstNameModified = ''; if (recipient.firstName !== '') {firstNameModified = ', ' + recipient.firstName;}%>Last Chance to Unlock $7 Walgreens Cash on Your Next Rx Pickup";
instance.vars.offer1PreviewText = "<% var firstNameModified = ''; if (recipient.firstName !== '') {firstNameModified = ', ' + recipient.firstName;}%>Fill Your Rx by 6/8 for Rewards!";
instance.vars.offer2SubjectLine = "<% var firstNameModified = ''; if (recipient.firstName !== '') {firstNameModified = ', ' + recipient.firstName;}%>Last Chance to Unlock $15 Walgreens Cash on Your Next Rx Pickup";
instance.vars.offer2PreviewText = "<% var firstNameModified = ''; if (recipient.firstName !== '') {firstNameModified = ', ' + recipient.firstName;}%>Fill Your Rx by 6/8 for Rewards!";
instance.vars.offer3SubjectLine = "<% var firstNameModified = ''; if (recipient.firstName !== '') {firstNameModified = ', ' + recipient.firstName;}%>We're making it easy to refill your Rx order";
instance.vars.offer3PreviewText = "Select free 1-2 day shipping on your next perscription";
instance.vars.getOption = getOption ('mdhCounter'); 


logInfo("Offer 1 Subject Line - " + instance.vars.offer1SubjectLine);
logInfo("Offer 2 Subject Line - " + instance.vars.offer2SubjectLine);
logInfo("Offer 3 Subject Line - " + instance.vars.offer3SubjectLine);
logInfo("Offer 1 Preview Text - " + instance.vars.offer1PreviewText);
logInfo("Offer 2 Preview Text - " + instance.vars.offer2PreviewText);
logInfo("Offer 3 Preview Text - " + instance.vars.offer3PreviewText);
logInfo ("Option = " + instance.vars.getOption);
//The following Process will create a function that will select the 4th Wednesday of every month as the MailDate


var currentDate = new Date();
var month = currentDate.getMonth();
var year = currentDate.getFullYear();

//GET FOURTH WEDNESDAY OF MONTH AS MAILDATE


function getFourthWednesday (year, month) {

var date = new Date(year, month, 1);
var day = date.getDay();
var daysUntilFourthWednesday = (3 - day +7)%7 + 21;

return new Date(year, month, daysUntilFourthWednesday + 1);
}


var fourthWednesday = getFourthWednesday(year, month);

instance.vars.newMailDate = fourthWednesday.toLocaleDateString();

//USE THE BELOW VARIABLE TO ENTER MAIL DATE MANUALLY - COMMENT OUT THE ABOVE instance.vars.newMailDate 

//instance.vars.newMailDate = new Date("12/06/2023");

logInfo ("Current Date: " + currentDate);
logInfo ("MailDate: " + instance.vars.newMailDate);  
//logInfo ("Month: " + month);
//logInfo ("Year: " + year);


//The following Process will create a function that will select the 3rd Wednesday of every month as the MailDate

var currentDate = new Date(new Date().toDateString());
var month = currentDate.getMonth();
var year = currentDate.getFullYear();

//GET FIRST WEDNESDAY OF MONTH AS MAILDATE

function getFirstWednesday (year, month) {

var date = new Date(year, month,1);
var day = date.getDay();
var daysUntilWednesday = (10 - day)%7;

return new Date(year, month, daysUntilWednesday +1);
}

//GET THIRD WEDNESDAY OF MONTH AS MAILDATE

function getThirdWednesday (year, month) {

var date = new Date(year, month, 1);
var day = date.getDay();
var daysUntilThirdWednesday = (3 - day +7)%7 + 14;

return new Date(year, month, daysUntilThirdWednesday + 1);
}

var firstWednesday = getFirstWednesday (year, month); 
var thirdWednesday = getThirdWednesday(year, month);
var thirdWednesdayPlusOne = getThirdWednesday(year, month +1);

instance.vars.newMailDate = (currentDate <= firstWednesday) ? thirdWednesday.toLocaleDateString() : thirdWednesdayPlusOne.toLocaleDateString() ; 

//USE THE LINE BELOW FOR MANUAL CREATION OF MAIL DATE. COMMENT OUT THE "instance.vars.newMailDate" CODE ABOVE

//instance.vars.newMailDate = new Date("07/19/2023").toLocaleDateString();

logInfo ("Month: " + month);
logInfo ("Year: " + year);
logInfo ("First Wednesday MailDate: " + firstWednesday);  
logInfo ("Current Date: " + currentDate);
logInfo ("MailDate: " + instance.vars.newMailDate); 






https://usnconeboxax1aos.cloud.onebox.dynamics.com/api/services/NW_ProcurementSummaryServiceGroup/NW_ProcurementSummaryService/ProcSummary

{
    "$id": "1",
    "TotalActiveSup": 6,
    "TotalBlackListedSup": 3,
    "TotalActivePR": 47,
    "TotalActiveRFQ": 15,
    "TotalActiveContract": 1,
    "TotalInactivePR": 301,
    "TotalInactiveRFQ": 0,
    "TotalInactiveContract": 21,
    "CompInvoice": 1,
    "ApprovedSup": 2
}
import java.util.*;
public class LinearSearch{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int count=0;
        System.out.println("Enter size of an array");
        int n=sc.nextInt();
        int[] arr=new int[n];
        System.out.println("Enter "+n+ " elements");
        for(int i=0;i<arr.length;i++)
        {
            arr[i]=sc.nextInt();
        }
        System.out.println("Enter key value to search");
        int target=sc.nextInt();

        for(int ele:arr)
        {
        if(ele==target)
            count++;
            System.out.println("ELEMENT FOUND ");
        }
        System.out.println("Arrays elements are"+Arrays.toString(arr));
        System.out.println("KEY VALUE :"+target);
        //System.out.println("number of times it repeats >"+target+"are"+count);
         System.out.println("element found at index :"+arr[target]);
    }
}
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter the no of days");
        int rowsize = sc.nextInt();
        sc.nextLine();
        double [][] sales = new double[rowsize][];
        System.out.println(Arrays.toString(sales));
        double sum =0.0;
        for(int i=0;i<rowsize;i++){
            System.out.println("Enter the no of sales on day "+(i+1));
            int n = sc.nextInt();
            sc.nextLine();
            sales[i]=new double[n];
            System.out.println("enter the amount for day "+(i+1));
            for(int j=0;j<n;j++){
                sales[i][j] = sc.nextDouble();
                sum+=sales[i][j];
            }
        }
        for(int i=0;i<sales.length;i++){
        System.out.println("say :"+(i+1)+" ---> "+Arrays.toString(sales[i]));
        }
        System.out.println("Average sale ----> "+(sum/rowsize));
    }
}
import java.util.*;
public class ArrayDemo{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        double average=0.0,sum=0.0;
        System.out.println("Enter the size");
        int size=sc.nextInt();
        int[] marks=new int[size];
        System.out.println("Enter " +size+"marks");
        for(int i=0;i<marks.length;i++){
            marks[i]=sc.nextInt();
            sum+=marks[i];
        }
         average=sum/size;
        System.out.println("Arrays elements are"+Arrays.toString(marks));
        System.out.println("SUM="+sum);
        System.out.println("Average ="+average);
    }
}
import java.util.*;
public class ArrayCount{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int count=0;
        System.out.println("Enter size of an array");
        int n=sc.nextInt();
        int[] arr=new int[n];
        System.out.println("Enter "+n+ " elements");
        for(int i=0;i<arr.length;i++)
        {
            arr[i]=sc.nextInt();
        }
        System.out.println("Enter target value");
        int target=sc.nextInt();

        for(int ele:arr)
        {
            if(ele>=target)
            count++;
        }
        System.out.println("Arrays elements are"+Arrays.toString(arr));
        System.out.println("Target"+target);
        System.out.println("number of elements >"+target+"are"+count);
    }
}
import java.util.Arrays;
import java.util.Scanner;

public class StringSort {
    public static void main(String[] args) {
        Scanner ip = new Scanner(System.in); // Corrected: System.in should be passed as an argument
        System.out.println("Enter the number of words you are supposed to enter: ");
        int n = ip.nextInt();
        ip.nextLine(); // Consume the newline character after reading the integer

        String[] str = new String[n];
        for (int i = 0; i < str.length; i++) {
            System.out.println("Enter word " + (i + 1) + ":");
            str[i] = ip.nextLine();
        }

        System.out.println("Strings before they are sorted: " + Arrays.toString(str));
        String[] str1 = sort(str);
        System.out.println("Strings after they are sorted are: " + Arrays.toString(str1));
    }

    private static String[] sort(String[] str1) {
        String temp;
        for (int i = 0; i < str1.length - 1; i++) {
            for (int j = 0; j < str1.length - i - 1; j++) {
                if (str1[j].compareTo(str1[j + 1]) > 0) {
                    temp = str1[j];
                    str1[j] = str1[j + 1];
                    str1[j + 1] = temp;
                }
            }
        }
        return str1;
    }
}
//import java.util.*;
public class StringObject{
    public static void main(String[] args) {
        String s1="OOPJ";
        String s2="object oriented program";
        String s3="OOPJ";
        String s4=s3;
        String s5=new String("OOPJ");
        String s6=new String("object oriented program");
        System.out.println("s1 and s2 have same reference :"+(s1==s2));
        System.out.println("s3 and s4 have same reference :"+(s3==s4));
        System.out.println("s1 and s5 have same reference :"+(s1==s5));
        System.out.println("s2 and s6 have same reference :"+(s2==s6));
        System.out.println("s3 and s6 have same reference :"+(s3.equals(s5)));
        System.out.println("s2 and s6 have same reference :"+(s2.equalsIgnoreCase(s6)));         



    }
}
package cvr.myapp.bean;

public class Person {

private String name;

private int age;

public Person(){}

public Person (String name, int age) {

this.name = name;

this .age = age:

}
public string toString(){ } return name+" "+age;
///////

package cvr.myapp.service;

import cvr.myapp.bean. Person;

public class Main {

public static void main(String[] args) {

Person p1 = new Person( "Person",35)

System.out.println(p1); 
  Person P2= new Person();

System.out.println (p2);

}
public class StringBuilders {
    public static void main(String[] args) {
        String str="ABCDEFGH";
        System.out.println("string length="+str.length());
        System.out.println("string replace:"+str.replace("ABCDEFGH","abcdefgh"));
        System.out.println("Index:"+str.indexOf("D"));
        System.out.println("string charat: "+str.charAt(5));
        System.out.println("string uppercase: "+str.toUpperCase());
        System.out.println("string lowercase: "+str.toLowerCase());
        System.out.println("string tostring"+str.toString());
        System.out.println("string concat"+str.concat("I"));
        //System.out.println("capitalize: "+str.capitalize());


    }
}
/**
 * Person
 */
public class Person {

    private int id;
    private String name;
    public void setData(int no,String str){
        id=no;
        name=str;
    }
    public void show(){
        System.out.println(id+" "+name);
    }
}




public class PersonDemo {
    public static void main(String[] args) {
        Person p=new Person();
        p.setData(101, "personone");
        p.show();
    }
}
import java.util.*;
public class  Palindrome{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter a string");
        String str=sc.nextLine();
        if(ispalindrome(str)){
            System.out.println(str+ "is palindrome");
        }
        else{
            System.out.println(str+ " is not a palindrome");
        }
    }
    private static boolean ispalindrome(String str){
        int i=0;
        int j=str.length()-1;
        while(i<=j){
            if(str.charAt(i)!=str.charAt(j))
                return false;
                i++;
                j--;
            }
            
        
        return true;
    }
}
import java.util.Scanner;
public class Indices {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter the string");
        String s = sc.nextLine();
        System.out.println("Enter the word");
        String wr = sc.nextLine();
        findind(s,wr);
    }
    private static void findind(String s, String wr) {
        int index = s.indexOf(wr);
        while(index!=-1){
            System.out.println("Index of "+wr+" :"+index);
            index = s.indexOf(wr,index+1);
        }
        if(index==-1&&s.indexOf(wr)==-1){
            System.out.println("The word "+wr+" is not found");
        }
    }
}
import java.util.*;
public class Main  {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter a string");
        String str=sc.nextLine();
        String rev = "";
        for(int i=str.length()-1;i>=0;i--){
            rev = rev + str.charAt(i);
        }
            System.out.println(rev);
        }
}
import java.util.*;
public class MatrixSum {
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args) {
        
        System.out.println("Enter matrix size(m,n)");
 
        int m=sc.nextInt();
        int n=sc.nextInt();
        int A[][]=readMatrix(m,n);
        int B[][]=readMatrix(m,n);
        int C[][]=sum(A,B);

        System.out.println("MATRIX-A");
        display(A);

        System.out.println("MATRIX-B");
        display(B);

        System.out.println("SUM-MATRIX");
        display(C);
    }

    private static int[][] readMatrix(int m,int n){
        int[][] matrix =new int[m][n];
        System.out.println("Enter elements "+m+"*"+n);
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                matrix[i][j]=sc.nextInt();
            }
        }
        return matrix;

    }

 private static void display(int[][] matrix){
     for (int[] row:matrix){
         for(int ele:row){
             System.out.print(ele+" ");
         }
         System.out.println();
     }
 }


    private static int[][] sum(int[][] A,int[][] B){
        int[][] matrix=new int[A.length][A[0].length];
        for(int i=0;i<A.length;i++){
            for(int j=0;j<B.length;j++){
                matrix[i][j]=A[i][j]+B[i][j];

            }
        }
        return matrix;
    }
}
import java.util.Scanner;

public class GreaterThanOrEqualCount {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("Enter the size of the array:");
        int size = sc.nextInt();

        int[] numbers = new int[size];

        System.out.println("Enter the elements of the array:");

        for (int i = 0; i < size; i++) {
            numbers[i] = sc.nextInt();
        }

        System.out.println("Enter the number to compare:");
        int compare = sc.nextInt();

        int count = 0;

        for (int number : numbers) {
            if (number >= compare) {
                count++;
            }
        }

        System.out.println("Number of elements greater than or equal to " + compare  + ": " + count);

        sc.close();
    }
}
import java.util.*;

public class GCD {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter two numbers");
        int a = sc.nextInt();
        int b = sc.nextInt();
        int result = gcd(a, b);
        System.out.println("GCD of " + a + "," + b + " is " + result);
        sc.close();
    }

    private static int gcd(int a, int b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
}
import java.util.Scanner;

public class GradeCalculator {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);

        System.out.println("Enter the percentage obtained by the student:");
        double percentage = sc.nextDouble();

        char grade;

        if (percentage >= 90) {
            grade = 'A';
        } else if (percentage >= 80) {
            grade = 'B';
        } else if (percentage >= 70) {
            grade = 'C';
        } else if (percentage >= 60) {
            grade = 'D';
        } else if (percentage >= 50) {
            grade = 'E';
        } else {
            grade = 'F';
        }

        switch (grade) {
            case 'A':
                System.out.println("Grade: A - Excellent");
                break;
            case 'B':
                System.out.println("Grade: B - Very Good");
                break;
            case 'C':
                System.out.println("Grade: C - Good");
                break;
            case 'D':
                System.out.println("Grade: D - Satisfactory");
                break;
            case 'E':
                System.out.println("Grade: E - Sufficient");
                break;
            case 'F':
                System.out.println("Grade: F - Fail");
                break;
            default:
                System.out.println("Error: Invalid grade");
        }

        sc.close();
    }
}
public class Course {
    private static int  nextId=1200;
    private int id;
    private  String name;
    private int credits;
    public Course(){
        id=nextId++;
    }

    public Course(String name ,int credits){
        id=nextId;
        this.credits=credits;
        this.name=name;
    }
    public int getId(){
        return id;
    }
    
    public String getName(){
        return name;
    }
    
    public void setName(String name){
        this.name=name;
    }
    public int getcredits(){
        return credits;
    }

    public void setCredits(int credits){
        this.credits=credits;

    }

    public static void setnextId(int nextId){
        Course.nextId=nextId;
    }

    public static int getNextID(){
        return nextId;
    }
    public String toString(){
        return "Course ID:"+id+ "\nCourse NAME:" +name+ "Credits:"+credits;
    }

}




public class CourseDemo {
    public static void main(String[] args) {
        Course c1=new Course();
        c1.setName("OOPJ");
        c1.setCredits(3);
        System.out.println(c1);
        Course c2=new Course("COSM", 3);
        System.out.println(c2);

    }
}
import java.util.*;
public class Command {
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        System.out.println("Arguments are:"+Arrays.toString(args));
        System.out.println("Enter key");
        String key=sc.nextLine();
        for(int i=0;i<args.length;i++){
            if(key.equals(args[i])){
                System.out.println("Key Found at: "+i);
                break;
            }
        }
    }
}
import java.util.Scanner;

public class SimpleCalculator {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("Enter first number:");
        double num1 = sc.nextDouble();

        System.out.println("Enter second number:");
        double num2 = sc.nextDouble();

        System.out.println("Select operation (+, -, *, /):");
        char operation = sc.next().charAt(0);

        double result;

        switch (operation) {
            case '+':
                result = num1 + num2;
                System.out.println("Result: " + result);
                break;
            case '-':
                result = num1 - num2;
                System.out.println("Result: " + result);
                break;
            case '*':
                result = num1 * num2;
                System.out.println("Result: " + result);
                break;
            case '/':
                if (num2 != 0) {
                    result = num1 / num2;
                    System.out.println("Result: " + result);
                } else {
                    System.out.println("Error: Cannot divide by zero.");
                }
                break;
            default:
                System.out.println("Error: Invalid operation.");
        }

        sc.close();
    }
}
import java.util.*;
public class CountDigits{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int[] resArr;
        System.out.println("Enter a number");
        int num=sc.nextInt();
        resArr=count(num);
        for(int i=0;i<resArr.length;i++){
            if(resArr[i]!=0){
                System.out.println(i+"-"+resArr[i]);
            }
        }
    }
    private static int[] count(int num){
        int[] arr=new int[10];
        while(num!=0){
            int digit=num%10;
            arr[digit]+=1;
            num/=10;
        }
        return arr;
    }
}
   public class Box{
    private double length;
    private double width;
    public Box(){
        System.out.println("box_default constructor");
        length=10;
        width=20;
    }
    public Box(double length,double width){
        System.out.println("box_parameterized constructor");
        this.length=length;
        this.width=width;
    }
    public String toString(){
        return "length:"+length+"\nwidth:"+width;
    }
   }

public class BoxColor extends Box{
    private String color;
    public Box color(){
        System.out.println("boxcolor-default constructor");
        color="brown";
    }
    public BoxColor(double length,double width,String color){
        super(length,width);
        this.color=color;
    }
}

public class BoxRating{
    private double rating;
public Box Rating(){}
    public BoxRating(double rating){this.rating=rating;}
    public BoxRating(double length,doublr width,String color,double rating)
    {
        super(length,width,color);
        this.rating=rating;
    }
    public String toString(){
        return super .toString()+"\n Rating"+rating;
    }
}

public class Main {
    public static void main(String[] args) {
        BoxRating b1=new BoxRating();
        System.out.println(b1);
        System.out.println();

        BoxRating b1=new BoxRating(5);
        System.out.println(b1);
        System.out.println();

        BoxRating b1=new BoxRating(20,30,"red",4.5);
        System.out.println(b1);
        System.out.println();
    }
}
public class Trycatch {
    public static void main(String[] args) {
        try{
            doSomething();
        }catch(Exception e){
            System.out.println(e);
        }
        
        
    }
    static void doSomething() throws Exception {
            throw new Exception("This is checked exception");
        }
}
import java.util.*;
public class IncSeq{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int[] arr;
        System.out.println("Enter array size");
        int n=sc.nextInt();
        arr=new int[n];
        System.out.println("Enter"+ n + "elements");
        for(int i=0;i<arr.length;i++){
            arr[i]=sc.nextInt();
        }
        int count=getcount(arr);
        System.out.println("Elements" +Arrays.toString(arr));
        System.out.println("No.of increasing sequences"+count);
    }

    private static int getcount(int[] arr){
        int count=0;
        for(int i=0;i<arr.length-1;){
            boolean flag=false;
            while(i<arr.length-1 && arr[i]<arr[i+1])
            {
                flag=true;
                i++;
            }
            if (flag)
                count++;
            else 
            i++;
        }
        return count;
        }
    }
import java.io.BufferedReader;
import java.io.FileReader;

public class Count {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("Data.txt"));
        int charCount =0;
        int wordCount=0;
        int lineCount=0;
        String line = null;
        while((line=br.readLine())!=null){
            lineCount++;
            wordCount+=line.split(" ").length;
            charCount+=line.length()+1;
        }
        System.out.println("Character: "+charCount);
        System.out.println("Word: "+wordCount);
        System.out.println("Line: "+lineCount);
    }
}
import java.util.*;
public class StringDemo{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    System.out.println("Arguments are "+Arrays.toString(args));
    System.out.println("Enter key: ");
    String key=sc.nextInt();
    for(int i=0;i<args.length;i++){
      if(key.equals(args[i])){
        System.out.println("Found");
      }
      break;
    }
  }
}
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Copy {
    public static void main(String[] args) {
        if (args.length != 2) {
            System.out.println("Usage: java Copy <sourceFilePath> <destinationFilePath>");
            return;
        }

        try (
            FileInputStream fis = new FileInputStream(args[0]);
            FileOutputStream fos = new FileOutputStream(args[1])
        ) {
            byte[] contents = new byte[fis.available()];
            fis.read(contents);
            fos.write(contents);
            System.out.println("Contents Copied");
        } catch (FileNotFoundException e) {
            System.out.println("File not found: " + e.getMessage());
        } catch (IOException e) {
            System.out.println("Error reading or writing the file: " + e.getMessage());
        }
    }
}
import java.util.Arrays;
import java.util.Scanner;
public class Custom {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[5];
        for(int i=0;i<5; ){
            System.out.println("Enter marks: "+(i+1));
            arr[i]=sc.nextInt();
        
            if(arr[i]<0 ||arr[i]>20){
                try{
                    throw new InvalidMarksException(arr[i]+" ");
                }catch(InvalidMarksException e){
                    System.out.println(e);
                }
            }
            else{i++;}
            System.out.println(Arrays.toString(arr));
        
        }
    }
}
  
  ////
  
  
import java.util.*;
class InvalidMarksException extends Exception{
 InvalidMarksException(){
    super("marks are invalid");
 }   
 InvalidMarksException(String msg){
    super("marks are invalid"+msg);

 }
 public String tostring(){
    return super.getMessage();
 }
}
public class PlayThread extends Thread{
    String songname;
    public PlayThread(String tname,String songname){
        super(tname);
        this.songname=songname;
    }
    public void run(){
        System.out.println("In Thread-"+this.getName());
    for(int i=1;i<=10;i++){
        System.out.println("Playing"+songname);
    }
    System.out.println("Done Playing");
}
}




public class Download extends Thread {
    String songname;
    public Download(String dname,String songname){
        super(dname);
        this.songname=songname;
    }

    public void run(){
        System.out.println("In Thread-"+this.getName());
    for(int i=1;i<=10;i++){
        System.out.println("Downloading"+songname);
    }
    System.out.println("Downloaded");
}
}




public class Main {
    public static void main(String[] args) {
        System.out.println("In Main Thread");
        PlayThread t1=new PlayThread("Play-Thread", "song-1");
        Download t2=new Download("Downloading Thread", "song-1");
        t1.start();
        t2.start();
        System.out.println("DONE");
    }
}
import java.util.*;

public class MultipleExceptions {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        try{
            System.out.println("Enter marks separated by ,");
            String[] marks=sc.nextLine().split(",");
            int sum=findSum(marks);
          System.out.println("Sum: "+sum);
            System.out.println("Average marks:"+sum/marks.length);
        }
        catch(ArrayIndexOutOfBoundsException e){
            System.out.println(e);
        }catch(NumberFormatException e){
            System.out.println(e);
        }catch(Exception e){
            System.out.println(e);
        }finally{
            System.out.println("This is executed always");
        }
    }

    public static int findSum(String[] marks){
        int sum=0;
        //String[] marks;
        for(int i=0;i<marks.length;i++){
            sum+=Integer.parseInt(marks[i]);
        }
        return sum;
    }
}
public class ElectricityBill implements Runnable {
    private int units;
    private double bill;
    private double unitcost=2.10;
    public ElectricityBill (int units){
        this.units=units;
    }
    public void run(){
        String tname=Thread.currentThread().getName();
        System.out.println(tname +"Bill Calculation Started:");
        try{
           Thread.sleep(10);

        }
        catch(InterruptedException e){
            e.printStackTrace();
        }
        bill =units<=250?300:300+(units-250)*unitcost ;
        System.out.println("Bill Form:"+tname+" ,"+bill);
    }
    public double getBill(){
        return bill;
    }

    
}






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

        ElectricityBill house1=new ElectricityBill(200);
        ElectricityBill house2=new ElectricityBill(500);
        ElectricityBill house3=new ElectricityBill(400);

        Thread t1=new Thread(house1,"house1");
        Thread t2=new Thread(house2,"house2");
        Thread t3=new Thread(house3,"house3");

        t1.start();
        t2.start();
        t3.start();

        try{
            t1.join();
            t2.join();
            t3.join();

        }catch(InterruptedException e){
            e.printStackTrace();
        }

        double TotalRevenue=house1.getBill()+house2.getBill()+house3.getBill();
        System.out.println("Total Revenue is :"+TotalRevenue);

    }
}
public class Inheritance {
    private String name;
    private int age;
    public String getName(){
        return name;
    }
    public void setName(String name){
        this.name=name;

    }
    public int getAge(){
        return age;

    }
    public void setAge(int age){
        this.age=age;
    }
    public String tostring(){
    return "name:"+name+"\n age:"+age;
}

    
}


public class Student extends Inheritance{
    private int rollno;
    public int getrollno(){
        return rollno;
    }
    public void setRollNo(int rollno){
        this.rollno=rollno;

    }
    public String tostring(){
        return super.tostring()+"\n"+"roll number:"+rollno;
    }
}


public class Main{
    public static void main(String[] args){
        Student s1=new Student();
        System.out.println(s1+"\n");
        s1.setName("person1");
        s1.setAge(18);
        s1.setRollNo(101);
        System.out.println(s1);
    }
} 
public class PrintMessage {
    synchronized void print(String Msg){
        System.out.println("["+Msg+"]");
    }
}



public class MessageSend {
    public static Runnable getSender(PrintMessage p,String Msg){
        return new Runnable() {
            private PrintMessage pMsg=p;
            private String Message=Msg;
            public void run(){
                pMsg.print(Message);
            }
        };
    }
}



public class MessageMain {
    public static void main(String[] args) {
        PrintMessage pMsg=new PrintMessage();
        String n1="CVR",n2="College",n3="Engineering";
        Runnable r1=MessageSend.getSender(pMsg,n1);
        Runnable r2=MessageSend.getSender(pMsg,n3);
        Runnable r3=MessageSend.getSender(pMsg,n2);

        new Thread(r1).start();
        new Thread(r2).start();
        new Thread(r3).start();
    }
}
import java.util.Scanner;

public class RootsType{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    float det;
    double root1,root2;

    System.out.println("enter the number a,b,c");
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    det = b*b-4*a*c;
    root1 = (- b + Math.sqrt(det))/2*a;
    root2 = (- b - Math.sqrt(det))/2*a;
    if(det==0)
    System.out.println("Roots are real and equal");

    else if(det>0)
    System.out.println("roots are real and distinct");
    else
    System.out.println("roots are imaginary");
    System.out.println("root1:"+root1);
    System.out.println("root2:"+root2);

    }

}
public class Queue{
    private boolean Vset=false;
    private int n;
    public synchronized void get() throws Exception{
        while(!Vset){
            wait();
        }
        System.out.println("Got:"+n);
        Vset=false;
        notify();
    }

    public synchronized void put(int n)throws Exception{
        while (Vset) {
            wait();
        }
        this.n=n;
        System.out.println("Put:"+n);
        Vset=true;
        notify();
    }
}


public class ThreadService {
    public static Runnable getProducer(Queue q){
        return new Runnable() {
            private Queue queue=q;
            int i=1;
            public void run(){
                while (true) {
                    try{
                        queue .put(i++);
                    }catch(Exception e){
                        e.printStackTrace();
                    }
                    
                }
            }
        };
    }
        public static Runnable getConsumer(Queue q){
            return new Runnable() {
                private Queue queue=q;
                public void run(){
                while (true) {
                    try{
                        queue.get();
                    }catch(Exception e){
                        e.printStackTrace();
                    }
                }
            }
            };
        }
    
}


public class ProducerConsumerDemo {
    public static void main(String[] args) {
        Queue q=new Queue();
        new Thread(ThreadService.getProducer(q)).start();
        new Thread(ThreadService.getConsumer(q)).start();
    }
}
public class Box {
    private double width;
    private double height;
    private static int boxCount = 0;
    public Box() {
        boxCount++;
    }
    public Box(double width, double height) {
        this.width = width;
        this.height = height;
        boxCount++;
    }
    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    // toString method to display box information
    @Override
    public String toString() {
        return "Box{" +
                ", width=" + width +
                ", height=" + height +
                '}';
    }
    public static int getBoxCount() {
        return boxCount;
    }
}
public class BoxDemo {
    public static void main(String[] args) {
        Box box1 = new Box();
      	Scanner sc=new Sacnner(System.in);
       	Box[] boxarr=new Box[5];
      	System.out.println("Number of boxes created: " + Box.getBoxCount());
        for(int i=0;i<boxarr.length;i++){
          System.out.println("Enter "+(i+1)+" height width);
          double n1=sc.nextInt();
          double n2=sc.nextInt();
          boxarr[1]=new Box(n1,n2);
        }
      System.out.println("Boxes in array are: ");
      for(Box box:boxarr){
        System.out.println(box);
      }
    }
}
#!/bin/sh

for i in {1979..1980}
do
    echo "output: $i"
    dir2=$((i+1))
    cp /from/$i/FILE:$i-08* /from/$dir2/
    mv  /from/$i/FILE:$i-09* /from/$dir2/
    
    
done
import java.util.*
  public class Product {
    private int productId;
    private String productName;
    private double productPrice;
    public Product() {}
    public Product(int productId, String productName, double productPrice) {
        this.productId = productId;
        this.productName = productName;
        this.productPrice = productPrice;
    }
	public Product() {
        productId = 001;
        productName = "PEN";
        productPrice = 30.32;
    }
    @Override
    public String toString() {
        return "Product{" +
                "productId=" + productId +
                ", productName='" + productName + '\'' +
                ", productPrice=" + productPrice +
                '}';
    }

    public static void main(String[] args) {
        Product product1 = new Product(1, "Laptop", 999.99);
        System.out.println(product1.toString());
    }
}
import java.util.*;

public class Grade {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter marks:");
        int marks = sc.nextInt();

        if (marks >= 90 && marks < 100)
            System.out.println("Grade: S");
        else if (marks >= 80 && marks < 90)
            System.out.println("Grade: A");
        else
            System.out.println("Grade: B");
    }
}
star

Fri Jan 19 2024 06:43:01 GMT+0000 (Coordinated Universal Time)

@himanshupatel #woocommerce #wordpress

star

Fri Jan 19 2024 05:49:43 GMT+0000 (Coordinated Universal Time) https://tripleten.com/trainer/web/lesson/939f5e38-00bf-401b-bc2e-0974cbb6d05c/

@Marcelluki

star

Fri Jan 19 2024 05:15:26 GMT+0000 (Coordinated Universal Time)

@E23CSEU1151 #java

star

Fri Jan 19 2024 02:39:49 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=TrX6WCu5VNc

@Hammy711

star

Thu Jan 18 2024 22:31:53 GMT+0000 (Coordinated Universal Time) https://web.dev/learn/privacy/data?authuser

@Spsypg #html

star

Thu Jan 18 2024 19:10:54 GMT+0000 (Coordinated Universal Time)

@montezh2001

star

Thu Jan 18 2024 19:07:29 GMT+0000 (Coordinated Universal Time)

@montezh2001

star

Thu Jan 18 2024 19:06:28 GMT+0000 (Coordinated Universal Time)

@montezh2001

star

Thu Jan 18 2024 19:05:13 GMT+0000 (Coordinated Universal Time)

@montezh2001

star

Thu Jan 18 2024 19:03:40 GMT+0000 (Coordinated Universal Time)

@montezh2001

star

Thu Jan 18 2024 19:02:44 GMT+0000 (Coordinated Universal Time)

@montezh2001

star

Thu Jan 18 2024 18:37:40 GMT+0000 (Coordinated Universal Time)

@MinaTimo

star

Thu Jan 18 2024 18:25:19 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:24:57 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:24:36 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:24:12 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:23:53 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:23:31 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:22:24 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:22:13 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:21:43 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:21:29 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:21:13 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:20:52 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:20:32 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:20:12 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:19:43 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:19:28 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:18:59 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:18:44 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:18:26 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:17:41 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:17:11 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:16:45 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:16:27 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:16:00 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:15:28 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:15:22 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:15:05 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:14:35 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:14:11 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:13:42 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:13:19 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:12:55 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:12:28 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:12:02 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:05:34 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:00:53 GMT+0000 (Coordinated Universal Time)

@diptish #bash

star

Thu Jan 18 2024 17:44:16 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 17:35:17 GMT+0000 (Coordinated Universal Time)

@login

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension