diff --git a/JAVA/Circumferance.java b/JAVA/Circumferance.java new file mode 100644 index 00000000..e912fb1f --- /dev/null +++ b/JAVA/Circumferance.java @@ -0,0 +1,16 @@ +import java.util.Scanner; + +public class Circumferance { + + public static double circle(float r) { + double circum = 2 * 3.14 * r; + System.out.println("your circumfer" + circum); + return circum; + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + float r = sc.nextFloat(); + circle(r); + } +} diff --git a/JAVA/ClearBit.java b/JAVA/ClearBit.java new file mode 100644 index 00000000..b2c60e41 --- /dev/null +++ b/JAVA/ClearBit.java @@ -0,0 +1,17 @@ + +//This code clears or sets a bit value to "0" at a particular position given by user +import java.util.*; + +public class ClearBit { + public static void main(String args[]) { + Scanner sc = new Scanner(System.in); + System.out.print("Enter your number : "); + int no = sc.nextInt(); + System.out.print("Enter the bit postion you want to clear : "); + int pos = sc.nextInt(); + int bitMass = 1 << pos; + int notbitMass = ~bitMass; + int newnumber = notbitMass & no; + System.out.print("Your Final no. : " + newnumber); + } +} diff --git a/JAVA/Compare2.java b/JAVA/Compare2.java new file mode 100644 index 00000000..144f59e3 --- /dev/null +++ b/JAVA/Compare2.java @@ -0,0 +1,18 @@ +import java.util.*; + +public class Compare2 { + public static void main(String args[]) { + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + if (a == b) { + System.out.println("both are equal"); + } else { + if (a >= b) { + System.out.println("a is greater then b"); + } else { + System.out.println("b is greater then a"); + } + } + } +} diff --git a/JAVA/Contains_Duplicate.java b/JAVA/Contains_Duplicate.java new file mode 100644 index 00000000..eeb761b0 --- /dev/null +++ b/JAVA/Contains_Duplicate.java @@ -0,0 +1,34 @@ +import java.util.*; +import java.util.Scanner; + +class Contains_Duplicate { + public boolean ContainsDuplicate(int[] nums) { + Set s = new HashSet<>(); + for (int num : nums) { + if (!s.add(num)) { + return true; + } + } + return false; + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.print("Enter the size of array :"); + int size = sc.nextInt(); + int[] nums = new int[size]; + System.out.print("Enter the elements of array :"); + for (int i = 0; i < size; i++) { + nums[i] = sc.nextInt(); + } + + Contains_Duplicate obj = new Contains_Duplicate(); + if (obj.ContainsDuplicate(nums)) { + System.out.print("True"); // i.e it contains duplicate elements + } else { + System.out.print("False");// i.e it does not contains duplicate elements + } + sc.close(); + } + +} \ No newline at end of file diff --git a/JAVA/DateToDay.java b/JAVA/DateToDay.java new file mode 100644 index 00000000..1636709a --- /dev/null +++ b/JAVA/DateToDay.java @@ -0,0 +1,60 @@ +import java.util.*; + +public class DateToDay { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int day, month, year; + System.out.println("Enter (dd mm yyyy) : "); + day = sc.nextInt(); + month = sc.nextInt(); + year = sc.nextInt(); + int day_in_month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + + // to check wheather the inputed year is a leap or not and make changes + // according to it + if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { + day_in_month[2] = 29; + } + + // check weather input is valid or not + if (day < 1 || day > day_in_month[month]) { + System.out.print("The Day must range for 1 - " + day_in_month[month]); + return; + } + + if (month < 1 || month > 12) { + System.out.print("The Month must range from 1 - 12"); + } + // total day passes in month also in year + int passed_days = day; + for (int i = 1; i < month; i++) { + passed_days += day_in_month[i]; + } + // total day till this year + int total_days = (year - 1) * 365 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400 + passed_days; + int odd_day = total_days % 7; + switch (odd_day) { + case 0: + System.out.println("Sunday"); + break; + case 1: + System.out.println("Monday"); + break; + case 2: + System.out.println("Tuesday"); + break; + case 3: + System.out.println("Wednesday"); + break; + case 4: + System.out.println("Thursday"); + break; + case 5: + System.out.println("Friday"); + break; + case 6: + System.out.println("Saturday"); + break; + } + } +} diff --git a/JAVA/DiamondPattern.java b/JAVA/DiamondPattern.java new file mode 100644 index 00000000..1e365925 --- /dev/null +++ b/JAVA/DiamondPattern.java @@ -0,0 +1,20 @@ + +//not complete +import java.util.*; + +public class DiamondPattern { + public static void main(String[] args) { + int n = 5; + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + if (j <= i) { + System.out.print("*"); + } else { + System.out.print(" "); + } + } + + System.out.println(); + } + } +} diff --git a/JAVA/EvenOdd.java b/JAVA/EvenOdd.java new file mode 100644 index 00000000..30fae3a9 --- /dev/null +++ b/JAVA/EvenOdd.java @@ -0,0 +1,13 @@ +import java.util.*; + +public class EvenOdd { + public static void main(String args[]) { + Scanner sc = new Scanner(System.in); + int number = sc.nextInt(); + if (number % 2 == 0) { + System.out.println("even"); + } else { + System.out.println("odd"); + } + } +} \ No newline at end of file diff --git a/JAVA/Factorial.java b/JAVA/Factorial.java new file mode 100644 index 00000000..e9018f08 --- /dev/null +++ b/JAVA/Factorial.java @@ -0,0 +1,18 @@ +import java.util.*; + +public class Factorial { + public static void Factorial(int a) { + int fact = 1; + for (int i = a; i >= 1; i--) { + fact = fact * i; + } + System.out.println(fact); + return; + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + Factorial(a); + } +} diff --git a/JAVA/Floydstriangle.java b/JAVA/Floydstriangle.java new file mode 100644 index 00000000..3883e4ff --- /dev/null +++ b/JAVA/Floydstriangle.java @@ -0,0 +1,21 @@ + +import java.util.*; + +public class Floydstriangle { + public static void main(String[] args) { + int n = 5; + int m = 1; + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + if (j <= i) { + System.out.print(m + " "); + m++; + } else { + System.out.print(""); + } + + } + System.out.println(); + } + } +} diff --git a/JAVA/GCD.java b/JAVA/GCD.java new file mode 100644 index 00000000..7b45b4a8 --- /dev/null +++ b/JAVA/GCD.java @@ -0,0 +1,32 @@ +import java.util.*; + +public class GCD { + public static void GCD(int a, int b) { + if (a % b == 0) { + System.out.println("The GCD : " + b); + } else { + if (b % a == 0) { + System.out.println("The GCD : " + a); + } else { + if (a != b) { + if (a > b) { + a = a - b; + System.out.println("The GCD : " + a); + } else { + if (b > a) { + b = b - a; + System.out.println("The GCD : " + b + b); + } + } + } + } + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + GCD(a, b); + } +} \ No newline at end of file diff --git a/JAVA/Output.java b/JAVA/Output.java new file mode 100644 index 00000000..990e0371 --- /dev/null +++ b/JAVA/Output.java @@ -0,0 +1,9 @@ +import java.util.*; + +public class Output { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + String name = sc.nextLine(); + System.out.println(name); + } +} \ No newline at end of file diff --git a/JAVA/PowerFunction.java b/JAVA/PowerFunction.java new file mode 100644 index 00000000..1ffca6c1 --- /dev/null +++ b/JAVA/PowerFunction.java @@ -0,0 +1,18 @@ +import java.util.*; + +public class PowerFunction { + public static void power(int x, int n) { + int result = 1; + for (int i = 1; i <= n; i++) { + result = result * x; + } + System.out.println("result :" + result); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int x = sc.nextInt(); + int n = sc.nextInt(); + power(x, n); + } +} \ No newline at end of file diff --git a/JAVA/ProductCalculator.java b/JAVA/ProductCalculator.java new file mode 100644 index 00000000..b29dacd1 --- /dev/null +++ b/JAVA/ProductCalculator.java @@ -0,0 +1,16 @@ +import java.util.*; + +public class ProductCalculator { + public static int productCal(int a, int b) { + int product = a * b; + return product; + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + int product = productCal(a, b); + System.out.println(product); + } +} diff --git a/JAVA/ReversePyramid.java b/JAVA/ReversePyramid.java new file mode 100644 index 00000000..976ba44d --- /dev/null +++ b/JAVA/ReversePyramid.java @@ -0,0 +1,18 @@ + +import java.util.*; + +public class ReversePyramid { + public static void main(String[] args) { + int l = 4; + int b = 4; + for (int i = 1; i <= l; i++) { + for (int j = 1; j <= b; j++) { + if (i <= j) { + System.out.print("*"); + } + System.out.print(" "); + } + System.out.println(); + } + } +} \ No newline at end of file diff --git a/JAVA/RomanToInteger.java b/JAVA/RomanToInteger.java new file mode 100644 index 00000000..e69de29b diff --git a/JAVA/SB.java b/JAVA/SB.java new file mode 100644 index 00000000..f307263b --- /dev/null +++ b/JAVA/SB.java @@ -0,0 +1,44 @@ +public class SB { + public static void main(String args[]) { + // String name = "Sudarshan"; + StringBuilder name = new StringBuilder("Sudarshan"); + System.out.println(name); + + // add at the begin of string + name.insert(0, "U"); + System.out.println(name); + + // Delete any letter in string eg:r + name.deleteCharAt(5); + System.out.println(name); + + // replace charater at index + name.setCharAt(1, 'a'); + System.out.println(name); + + // add at the end of string + name.append(' '); + System.out.println(name); + name.append("Jadhav"); + System.out.println(name); + + // Reverse string + name.reverse(); + System.out.println(name); + + // OR + for (int i = 0; i < name.length() / 2; i++) { + int front = i; + int back = name.length() - 1 - i; + + char frontchar = name.charAt(front); + char backchar = name.charAt(back); + + name.setCharAt(front, backchar); + name.setCharAt(back, frontchar); + + } + System.out.println(name); + } + +} diff --git a/JAVA/SearchArray.java b/JAVA/SearchArray.java new file mode 100644 index 00000000..09113dab --- /dev/null +++ b/JAVA/SearchArray.java @@ -0,0 +1,25 @@ +import java.util.*; + +public class SearchArray { + public static void main(String args[]) { + Scanner sc = new Scanner(System.in); + System.out.println("Enter your size:"); + int size = sc.nextInt(); + int marks[] = new int[size]; + System.out.println("Enter your array:"); + for (int i = 0; i < size; i++) { + marks[i] = sc.nextInt(); + } + + System.out.println("\nEnter your search element:"); + int search = sc.nextInt(); + for (int i = 0; i < size; i++) { + if (marks[i] == search) { + System.out.println("your output :"); + System.out.println(i); + } + + } + } + +} diff --git a/JAVA/SetBit.java b/JAVA/SetBit.java new file mode 100644 index 00000000..707afb50 --- /dev/null +++ b/JAVA/SetBit.java @@ -0,0 +1,17 @@ + +//this code set the bit position given by the user to "1" +import java.util.*; + +public class SetBit { + public static void main(String args[]) { + Scanner sc = new Scanner(System.in); + System.out.print("Enter the number:"); + int no = sc.nextInt(); + System.out.print("Enter the position to change the bit:"); + int pos = sc.nextInt(); + int bitMass = 1 << pos; + int newno = bitMass | no; + System.out.println("Your Final no.:" + newno); + } + +} \ No newline at end of file diff --git a/JAVA/SolidRectangle.java b/JAVA/SolidRectangle.java new file mode 100644 index 00000000..cf099c30 --- /dev/null +++ b/JAVA/SolidRectangle.java @@ -0,0 +1,15 @@ +import java.util.*; + +public class SolidRectangle { + public static void main(String[] args) { + int b = 4; + int l = 5; + + for (int i = 1; i <= b; i++) { + for (int j = 1; j <= l; j++) { + System.out.print("*"); + } + System.out.println(); + } + } +} diff --git a/JAVA/SolidRhombus.java b/JAVA/SolidRhombus.java new file mode 100644 index 00000000..0934718e --- /dev/null +++ b/JAVA/SolidRhombus.java @@ -0,0 +1,17 @@ +import java.util.*; + +public class SolidRhombus { + public static void main(String[] args) { + int n = 5; + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n - i; j++) { + System.out.print(" "); + } + for (int j = 1; j <= n; j++) { + System.out.print("*"); + } + System.out.println(); + } + } +} diff --git a/JAVA/SumCalculator.java b/JAVA/SumCalculator.java new file mode 100644 index 00000000..5744a187 --- /dev/null +++ b/JAVA/SumCalculator.java @@ -0,0 +1,15 @@ +import java.util.*; + +public class SumCalculator { + public static int SumCal(int a, int b) { + int sum = a + b; + return sum; + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + int sum = SumCal(a, b); + System.out.println(sum); + } +} \ No newline at end of file diff --git a/JAVA/UpdateBit.java b/JAVA/UpdateBit.java new file mode 100644 index 00000000..1963e84e --- /dev/null +++ b/JAVA/UpdateBit.java @@ -0,0 +1,24 @@ + +//This code update the bit value to "1" or "0" according to thr user input +import java.util.*; + +public class UpdateBit { + public static void main(String args[]) { + Scanner sc = new Scanner(System.in); + System.out.print("Enter operation : "); + int opr = sc.nextInt(); + System.out.print("Enter the number : "); + int no = sc.nextInt(); + System.out.print("Enbter the positon : "); + int pos = sc.nextInt(); + int bitMass = 1 << pos; + if (opr == 1) { + int newBit = bitMass | no; + System.out.print("The Final number : " + newBit); + } else { + int notbitMass = ~bitMass; + int newBit = notbitMass & no; + System.out.print("The final number :" + newBit); + } + } +} diff --git a/JAVA/VotingIlligiblity.java b/JAVA/VotingIlligiblity.java new file mode 100644 index 00000000..cd354691 --- /dev/null +++ b/JAVA/VotingIlligiblity.java @@ -0,0 +1,19 @@ +import java.util.*; + +public class VotingIlligiblity { + public static void eligibility(int age) { + if (age >= 18) { + System.out.println("Your r eligiable to vote."); + } else { + System.out.println("You r not eligiable to vote."); + } + return; + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int age = sc.nextInt(); + eligibility(age); + } + +} diff --git a/JAVA/ZeroTo1Triangle.java b/JAVA/ZeroTo1Triangle.java new file mode 100644 index 00000000..5a66030a --- /dev/null +++ b/JAVA/ZeroTo1Triangle.java @@ -0,0 +1,22 @@ + +import java.util.*; + +public class ZeroTo1Triangle { + public static void main(String[] args) { + int l = 5; + for (int i = 0; i <= l; i++) { + for (int j = 1; j <= l; j++) { + if (j <= i) { + int a; + a = j; + a = a % 2; + System.out.print(a); + } else { + System.out.print(" "); + } + } + + System.out.println(); + } + } +} \ No newline at end of file diff --git a/JAVA/ZeroToTenDoWhile.java b/JAVA/ZeroToTenDoWhile.java new file mode 100644 index 00000000..bc4dc239 --- /dev/null +++ b/JAVA/ZeroToTenDoWhile.java @@ -0,0 +1,15 @@ +import java.util.*; +public class ZeroToTenDoWhile +{ + + public static void main(String[] arg) + { + int i=1; + do + { + System.out.println(i); + i++; + } + while(i<10); + } +} diff --git a/JAVA/ZeroToTenForLoop.java b/JAVA/ZeroToTenForLoop.java new file mode 100644 index 00000000..9f07dc19 --- /dev/null +++ b/JAVA/ZeroToTenForLoop.java @@ -0,0 +1,11 @@ +import java.util.*; +public class ZeroToTenForLoop +{ + public static void main(String args[]) + { + for(int i=0;i<=10;i++) + { + System.out.println(i); + } + } +} diff --git a/JAVA/ZeroToTenWhile.java b/JAVA/ZeroToTenWhile.java new file mode 100644 index 00000000..7d4e9348 --- /dev/null +++ b/JAVA/ZeroToTenWhile.java @@ -0,0 +1,13 @@ +import java.util.*; +public class ZeroToTenWhile +{ + public static void main(String[] args) + { + int i = 1; + while(i<=10) + { + System.out.println(i); + i++; + } + } +} \ No newline at end of file diff --git a/JAVA/employeecode.java b/JAVA/employeecode.java new file mode 100644 index 00000000..f7c90d43 --- /dev/null +++ b/JAVA/employeecode.java @@ -0,0 +1,68 @@ +import java.util.*; + +public class employeecode { + public static class Employee { + String name; + int age; + double salary; + + public Employee(String name, int age, double salary) { + this.name = name; + this.age = age; + this.salary = salary; + } + + public String getName() { + return name; + } + + public int getage() { + return age; + + } + + public void setage(int age) { + this.age = age; + } + + public double getsalary() { + return salary; + } + + public void setsalary(double salary) { + this.salary = salary; + } + + public void raisesalary() { + this.salary += this.salary * 0.1; + } + } + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + System.out.println("Enter the employee's name:"); + String name = scanner.nextLine(); + + System.out.println("Enter the employee's age:"); + int age = scanner.nextInt(); + + System.out.println("Enter the employee's salary:"); + double salary = scanner.nextDouble(); + + Employee emp = new Employee(name, age, salary); + + System.out.println("Employee Details:"); + System.out.println("Name: " + emp.getName()); + System.out.println("Age: " + emp.getage()); + System.out.println("Salary: " + emp.getsalary()); + + emp.raisesalary(); + + System.out.println("\nName: " + emp.getName()); + System.out.println("Age: " + emp.getage()); + System.out.println("After 10% raise:"); + System.out.println("Salary: " + emp.getsalary()); + + scanner.close(); + } +} \ No newline at end of file diff --git a/PYTHON/Matplotlib/DefalutX-Points.py b/PYTHON/Matplotlib/DefalutX-Points.py new file mode 100644 index 00000000..93a1b0a3 --- /dev/null +++ b/PYTHON/Matplotlib/DefalutX-Points.py @@ -0,0 +1,35 @@ +#include +#include +using namespace std; +struct food +{ + int quantity; + char name; + float price; +}; + +int main() +{ + struct food Lunch; + struct food Breakfast; + cout<<"Enter the quantity of food : "; + cin>>Lunch.quantity; + cout<<"Enter the Starting letter of food : "; + cin>>Lunch.name; + cout<<"Enter the prince of food : "; + cin>>Lunch.price; + cout<>Breakfast.quantity; + cout<<"Enter the Starting letter of food : "; + cin>>Breakfast.name; + cout<<"Enter the prince of food : "; + cin>>Breakfast.price; + cout<