diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/Assignment1/com/company/Circle.class b/out/production/Assignment1/com/company/Circle.class
new file mode 100644
index 0000000..74d95bd
Binary files /dev/null and b/out/production/Assignment1/com/company/Circle.class differ
diff --git a/out/production/Assignment1/com/company/Cylinder.class b/out/production/Assignment1/com/company/Cylinder.class
new file mode 100644
index 0000000..194df0f
Binary files /dev/null and b/out/production/Assignment1/com/company/Cylinder.class differ
diff --git a/out/production/Assignment1/com/company/Main.class b/out/production/Assignment1/com/company/Main.class
new file mode 100644
index 0000000..8694f85
Binary files /dev/null and b/out/production/Assignment1/com/company/Main.class differ
diff --git a/out/production/Assignment1/com/company/Problem_statement_1.class b/out/production/Assignment1/com/company/Problem_statement_1.class
new file mode 100644
index 0000000..9d43ffb
Binary files /dev/null and b/out/production/Assignment1/com/company/Problem_statement_1.class differ
diff --git a/out/production/Assignment1/com/company/Rectangle.class b/out/production/Assignment1/com/company/Rectangle.class
new file mode 100644
index 0000000..bbb22d7
Binary files /dev/null and b/out/production/Assignment1/com/company/Rectangle.class differ
diff --git a/out/production/Assignment1/com/company/Sphere.class b/out/production/Assignment1/com/company/Sphere.class
new file mode 100644
index 0000000..2bee392
Binary files /dev/null and b/out/production/Assignment1/com/company/Sphere.class differ
diff --git a/out/production/Assignment1/com/company/Square.class b/out/production/Assignment1/com/company/Square.class
new file mode 100644
index 0000000..c590497
Binary files /dev/null and b/out/production/Assignment1/com/company/Square.class differ
diff --git a/out/production/Assignment1/com/company/Triangle.class b/out/production/Assignment1/com/company/Triangle.class
new file mode 100644
index 0000000..c572a3e
Binary files /dev/null and b/out/production/Assignment1/com/company/Triangle.class differ
diff --git a/src/com/Hotwax/www/Main.java b/src/com/Hotwax/www/Main.java
new file mode 100644
index 0000000..6afe9e8
--- /dev/null
+++ b/src/com/Hotwax/www/Main.java
@@ -0,0 +1,184 @@
+package com.company;
+import java.util.*;
+
+
+class Triangle{
+ int height;
+ int base;
+
+ void getDimensions(int h , int b){
+ height = h;
+ base = b;
+ }
+
+ void calculateArea(){
+ System.out.println((height*base)/2);
+ }
+
+ void calculatePerimeter(int a , int b , int c){
+ System.out.println(a+b+c);
+ }
+}
+class Rectangle{
+ void calculateArea(int l , int b){
+ System.out.println(l*b);
+ }
+ void calculatePerimeter(int l , int b){
+ System.out.println(2*l + 2*b);
+ }
+}
+class Square{
+ void calculateArea(int l ){
+ System.out.println(l*l);
+ }
+ void calculatePerimeter(int l){
+ System.out.println(4*l);
+ }
+}
+class Cylinder{
+ void calculateArea(int r, int h ){
+ System.out.println(2*3.14*r*h+ 2*3.14*r*r);
+ }
+ void calculatePerimeter(int r ){
+ System.out.println((2*3.14*r*r));
+ }
+ void calculateVolume(int r , int h ){
+ System.out.println(3.14 * r*r*h);
+ }
+}
+class Sphere{
+ void calculateArea(int r ){
+ System.out.println(4*3.14*r*r);
+ }
+ void calculatePerimeter(int r ){
+ System.out.println((2*3.14*r));
+ }
+ void calculateVolume(int r ){
+ System.out.println(3.14 * r*r*r * 1.34);
+ }
+}
+class Circle{
+ void calculateArea(int r){
+ System.out.println(3.14*r*r);
+ }
+ void calculatePerimeter(int r){
+ System.out.println((2*3.14*r));
+ }
+}
+public class Main {
+
+ public static void main(String[] args) {
+ // write your code here
+ while (true)
+ {
+ System.out.println("Enter shape : ");
+ Scanner sc = new Scanner(System.in);
+ String shape = sc.next();
+ if (shape.equalsIgnoreCase( "triangle")){
+ Triangle t = new Triangle();
+ System.out.println("Enter Operation to be performed : ");
+ String operation = sc.next();
+ if (operation.equalsIgnoreCase("area")){
+ System.out.print("Enter height of Triangle : ");
+ int height = sc.nextInt();
+ System.out.print("Enter base of Triangle : ");
+ int base = sc.nextInt();
+ t.getDimensions(height, base);
+ t.calculateArea();
+ }
+ if (operation.equalsIgnoreCase("perimeter")){
+ System.out.println("Enter length of first side");
+ int a = sc.nextInt();
+ System.out.println("Enter length of second side");
+ int b = sc.nextInt();
+ System.out.println("Enter length of third side");
+ int c = sc.nextInt();
+ t.calculatePerimeter(a,b,c);
+ }
+
+ }
+ else if (shape.equalsIgnoreCase("rectangle")){
+ Rectangle r = new Rectangle();
+ System.out.println("Enter Operation to be performed : ");
+ String operation = sc.next();
+ System.out.println("Enter length : ");
+ int l = sc.nextInt();
+ System.out.println("Enter breadth : ");
+ int b = sc.nextInt();
+ if (operation.equalsIgnoreCase("area")){
+ r.calculateArea(l,b);
+ }
+ else if (operation.equalsIgnoreCase("perimeter")){
+ r.calculatePerimeter(l,b);
+ }
+ }
+ else if (shape.equalsIgnoreCase("square")){
+ Square r = new Square();
+ System.out.println("Enter Operation to be performed : ");
+ String operation = sc.next();
+ System.out.println("Enter side : ");
+ int l = sc.nextInt();
+ if (operation.equalsIgnoreCase("area")){
+ r.calculateArea(l);
+ }
+ else if (operation.equalsIgnoreCase("perimeter")){
+ r.calculatePerimeter(l);
+ }
+ }
+ else if (shape.equalsIgnoreCase("cylinder")){
+ Cylinder c = new Cylinder();
+ System.out.println("Enter Operation to be performed : ");
+ String operation = sc.next();
+ System.out.println("Enter radius : ");
+ int r = sc.nextInt();
+ System.out.println("Enter height : ");
+ int h = sc.nextInt();
+ if (operation.equalsIgnoreCase("area")){
+ c.calculateArea(r,h);
+ }
+ else if (operation.equalsIgnoreCase("perimeter")){
+ c.calculatePerimeter(r);
+ }
+ else if (operation.equalsIgnoreCase("Volume")){
+ c.calculateVolume(r,h);
+ }
+ }
+ else if (shape.equalsIgnoreCase("circle")){
+ Circle c = new Circle();
+ System.out.println("Enter Operation to be performed : ");
+ String operation = sc.next();
+ System.out.println("Enter radius : ");
+ int r = sc.nextInt();
+ if (operation.equalsIgnoreCase("area")){
+ c.calculateArea(r);
+ }
+ else if (operation.equalsIgnoreCase("perimeter")) {
+ c.calculatePerimeter(r);
+ }
+ }
+ else if (shape.equalsIgnoreCase("Sphere")){
+ Sphere s = new Sphere();
+ System.out.println("Enter Operation to be performed : ");
+ String operation = sc.next();
+ System.out.println("Enter radius : ");
+ int r = sc.nextInt();
+ if (operation.equalsIgnoreCase("area")){
+ s.calculateArea(r);
+ }
+ else if (operation.equalsIgnoreCase("perimeter")) {
+ s.calculatePerimeter(r);
+ }
+ else if (operation.equalsIgnoreCase("Volume")) {
+ s.calculateVolume(r);
+ }
+ }
+ else if (shape.equalsIgnoreCase("done")){
+ break;
+ }
+ else{
+ System.out.println("shape not found");
+ }
+
+ }
+ }
+}
diff --git a/src/com/Hotwax/www/Problem_statement_1.java b/src/com/Hotwax/www/Problem_statement_1.java
new file mode 100644
index 0000000..d050579
--- /dev/null
+++ b/src/com/Hotwax/www/Problem_statement_1.java
@@ -0,0 +1,49 @@
+package com.company;
+import java.io.*;
+import java.util.Scanner;
+import java.net.*;
+
+
+public class Problem_statement_1 {
+ public static void main(String[] args) {
+ String[] a = new String[3];
+ try {
+ File obj1 = new File("url.txt");
+ Scanner r = new Scanner(obj1);
+ File f = new File("words.txt");
+ Scanner sc = new Scanner(f);
+ int j=0;
+ while (sc.hasNextLine()){
+// System.out.println(sc.nextLine());
+ a[j] = sc.nextLine();
+ j+=1;
+ }
+ while (r.hasNextLine()) {
+ String data = r.nextLine();
+ URL x = new URL(data);
+ BufferedReader in = new BufferedReader(new InputStreamReader(x.openStream()));
+ String inputLine;
+
+ int v=0,w=0,y=0;
+ while ((inputLine = in.readLine()) != null) {
+ String result = inputLine.replaceAll("<[^>]*>", "");
+ int count = (result.split(a[0]).length) - 1;
+ int count1 = (result.split(a[1]).length) - 1;
+ int count2 = (result.split(a[2]).length) - 1;
+ v += count;
+ w += count1;
+ y += count2;
+ }
+ System.out.println("Word "+a[0]+" has occurred "+v+" times");
+ System.out.println("Word "+a[1]+" has occurred "+w+" times");
+ System.out.println("Word "+a[2]+" has occurred "+y+" times");
+
+ in.close();
+ }
+ r.close();
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/com/Hotwax/www/Problem_statement_4_OverdrawnDemo.java b/src/com/Hotwax/www/Problem_statement_4_OverdrawnDemo.java
new file mode 100644
index 0000000..ce847a5
--- /dev/null
+++ b/src/com/Hotwax/www/Problem_statement_4_OverdrawnDemo.java
@@ -0,0 +1,39 @@
+package com.company;
+
+class Accountt extends Thread {
+ String name;
+ int balance = 1000;
+ int getBalance(){
+ return balance;
+ }
+ public void run(){
+ int i =0;
+ while(i<5){
+ balance = balance - 100;
+ System.out.println("b"+balance);
+ i+=1;
+ }
+
+ }
+}
+
+class AccountOverdrawDemo1 {
+ public void main() {
+ Accountt boy1 = new Accountt();
+ boy1.name = "vin";
+ boy1.run();
+ boy1.start();
+
+ for(int i =0 ; i<5;i++){
+ boy1.balance = boy1.balance-100;
+ System.out.println("a"+boy1.balance);
+ }
+ }
+}
+public class Problem_statement_4_OverdrawnDemo {
+ public static void main(String[] args) {
+ AccountOverdrawDemo1 acc = new AccountOverdrawDemo1();
+// AccountOverdrawDemo1 acc = new AccountOverdrawDemo1();
+ acc.main();
+ }
+}
diff --git a/src/com/Hotwax/www/Problem_statement_4_OverdrawnSafeDemo.java b/src/com/Hotwax/www/Problem_statement_4_OverdrawnSafeDemo.java
new file mode 100644
index 0000000..79de589
--- /dev/null
+++ b/src/com/Hotwax/www/Problem_statement_4_OverdrawnSafeDemo.java
@@ -0,0 +1,46 @@
+package com.company;
+
+class Account{
+ int balance = 1000;
+ void withdraw(String s , int b){
+ if (balance >= b){
+ balance = balance - b;
+ System.out.println(s +" withdrew "+b+" amount of money");
+ System.out.println("New balance " + balance);
+ }
+ else{
+ System.out.println("Not enough money");
+ }
+ }
+}
+
+class AccountOverdrawSafeDemo extends Thread{
+ Account ac;
+ String name;
+ int balance;
+ AccountOverdrawSafeDemo(Account ob, String n, int b)
+ {
+ ac = ob;
+ name = n;
+ balance = b;
+ }
+
+ public void run(){
+ ac.withdraw(name, balance);
+ }
+}
+
+public class Problem_statement_4_OverdrawnSafeDemo {
+ public static void main(String[] args) {
+ Account acc = new Account();
+ for (int i =0 ;i<5;i++){
+ AccountOverdrawSafeDemo a = new AccountOverdrawSafeDemo(acc, "a", 100);
+ a.start();
+ }
+ for (int i =0 ;i<5;i++){
+ AccountOverdrawSafeDemo b = new AccountOverdrawSafeDemo(acc, "b", 100);
+ b.start();
+ }
+ }
+
+}
diff --git a/src/com/Hotwax/www/Problem_statement_5.java b/src/com/Hotwax/www/Problem_statement_5.java
new file mode 100644
index 0000000..fcb8922
--- /dev/null
+++ b/src/com/Hotwax/www/Problem_statement_5.java
@@ -0,0 +1,76 @@
+package com.company;
+
+import java.io.*;
+
+class Student implements Serializable {
+ String firstname;
+ String dob;
+ Address address;
+ public Student(String firstname, String dob,Address address) {
+ this.firstname = firstname;
+ this.address = address;
+ this.dob = dob;
+ }
+ @Override
+ public String toString() {
+ return " Student First Name = " +firstname + "\n DOB = " + dob + "\n Address =" + address + "\n\n" ;
+ }
+}
+
+class Address implements Serializable {
+ String city;
+ String state;
+ int pincode;
+ String country;
+
+
+ public Address(String city, String state, int pincode, String country) {
+ this.city = city;
+ this.state = state;
+ this.pincode = pincode;
+ this.country = country;
+ }
+}
+public class Problem_statement_5 {
+ public static void main(String[] args) {
+ String fileName = "output1.ser";
+ Address add = new Address("Indore", "up", 123456,"India");
+ Student stu = new Student("veennayak","12/12/2000",add);
+ serializeObject(fileName,stu);
+ deserializeObject(fileName);
+ Student stu1 = new Student("vinayak","12/12/2000",add);
+ serializeObject(fileName,stu1);
+ deserializeObject(fileName);
+ Student stu2 = new Student("yak","12/12/2000",add);
+ serializeObject(fileName,stu2);
+ deserializeObject(fileName);
+ Student stu3 = new Student("vina","12/12/2000",add);
+ serializeObject(fileName,stu3);
+ deserializeObject(fileName);
+ }
+
+ private static void deserializeObject(String fileName) {
+ try(ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fileName))) {
+ Object object = ois.readObject();
+ Student st=(Student) object;
+ System.out.println(st);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void serializeObject(String fileName ,Student stu) {
+
+// Address ad = new Address("Indore", "up", 123456,"India");
+// Student st = new Student("vinayak","123",ad);
+// Address add = new Address("Indore", "up", 123456,"India");
+// Student stu = new Student("vinayak","123",ad);
+ try(ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(fileName))) {
+ oos.writeObject(stu);
+// oos.writeObject(stu);
+// System.out.println("serialized");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/com/Hotwax/www/problem_statement_3.java b/src/com/Hotwax/www/problem_statement_3.java
new file mode 100644
index 0000000..6dd05a8
--- /dev/null
+++ b/src/com/Hotwax/www/problem_statement_3.java
@@ -0,0 +1,322 @@
+package com.Hotwax.www;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Scanner;
+
+
+class NameComparator implements Comparator {
+ public int compare(Employee emp1, Employee emp2){
+ return emp1.getName().compareTo(emp2.getName());
+ }
+}
+class NameComparatorDesc implements Comparator {
+ public int compare(Employee emp1, Employee emp2){
+ return emp2.getName().compareTo(emp1.getName());
+ }
+}
+class AgeComparator implements Comparator {
+ public int compare(Employee emp1, Employee emp2){
+ return emp1.getAge().compareTo(emp2.getAge());
+ }
+}
+class AgeComparatorDesc implements Comparator {
+ public int compare(Employee emp1, Employee emp2){
+ return emp2.getAge().compareTo(emp1.getAge());
+ }
+}
+class EmailComparator implements Comparator {
+ public int compare(Employee emp1, Employee emp2){
+ return emp1.getEmail().compareTo(emp2.getEmail());
+ }
+}
+class EmailComparatorDesc implements Comparator {
+ public int compare(Employee emp1, Employee emp2){
+ return emp1.getEmail().compareTo(emp2.getEmail());
+ }
+}
+class DobComparator implements Comparator {
+ public int compare(Employee emp1, Employee emp2){
+ return emp1.getDob().compareTo(emp2.getDob());
+ }
+}
+class DobComparatorDesc implements Comparator {
+ public int compare(Employee emp1, Employee emp2){
+ return emp1.getDob().compareTo(emp2.getDob());
+ }
+}
+class Employee implements Comparable {
+ private String name;
+ private String email;
+ private String age;
+ private String dob;
+
+ Employee(String n, String e, String a, String d){
+ name = n;
+ email = e;
+ age= a;
+ dob = d;
+ }
+ public String toString(){
+ return name+","+email+","+age+","+dob;
+ }
+
+ public int compareTo(Employee e){
+ return name.compareTo(e.getName());
+ }
+
+ public String getName(){
+ return name;
+ }
+ public String getEmail(){
+ return email;
+ }
+ public String getDob(){
+ return dob;
+
+ }
+ public String getAge(){
+ return age;
+ }
+
+
+
+ void add(String n, String e, String a, String d) {
+ name = n;
+ email = e;
+ age = a;
+ dob = d;
+
+ try {
+ int count = 0;
+ FileWriter mw = new FileWriter("employee.txt", true);
+ File obj = new File("employee.txt");
+ Scanner reader = new Scanner(obj);
+ BufferedWriter out = new BufferedWriter(mw);
+ while (reader.hasNextLine()) {
+ String data = reader.nextLine();
+ count = (data.split("," + e + ",").length) - 1;
+ }
+ if (count < 1) {
+ out.write(name + "," + email + "," + age + "," + dob + "\n");
+ System.out.println("written");
+ } else {
+ System.out.println("email already exists.");
+ }
+ out.close();
+
+
+ } catch (IOException er) {
+ System.out.println("some error occurred");
+ er.printStackTrace();
+ }
+ }
+
+ void SearchRec(String e) {
+ try {
+ File obj = new File("employee.txt");
+ Scanner reader = new Scanner(obj);
+ int i = 0;
+ int flag = 0;
+ while (reader.hasNextLine()) {
+ String data = reader.nextLine();
+ int count = (data.split("," + e + ",").length) - 1;
+ if (count > 0) {
+ flag = 1;
+ }
+ i += 1;
+ }
+ reader.close();
+ if (flag == 1) {
+ System.out.println("Found at line " + i);
+
+ } else {
+ System.out.println("Not Found");
+ }
+ } catch (FileNotFoundException er) {
+ System.out.println("error found");
+ er.printStackTrace();
+ }
+ }
+
+ void DeleteRec(String e) {
+ String tempFile = "employee1.txt";
+ File oldFile = new File("employee.txt");
+ File newFile = new File("employee1.txt");
+
+ String current;
+ try {
+ FileWriter fw = new FileWriter(tempFile, true);
+ BufferedWriter bw = new BufferedWriter(fw);
+ PrintWriter pw = new PrintWriter(bw);
+
+ FileReader fr = new FileReader("employee.txt");
+ BufferedReader br = new BufferedReader(fr);
+// int count = (data.split("," + e + ",").length) - 1;
+ while ((current = br.readLine()) == null) {
+ try {
+ if (current.split("," + e + ",").length != 1) {
+ pw.println(current);
+ }
+ }
+ catch (NullPointerException error){
+ System.out.println(error);
+ }
+
+
+ }
+ pw.flush();
+ pw.close();
+ fr.close();
+ br.close();
+ bw.close();
+ fw.close();
+
+ oldFile.delete();
+ File dump = new File("employee.txt");
+ newFile.renameTo(dump);
+ } catch (Exception em) {
+ System.out.println("Handled");
+ }
+ }
+
+ public void sortIt(String orderBy) {
+ ArrayList employees = new ArrayList<>();
+ try {
+ File obj = new File("employee.txt");
+ Scanner reader = new Scanner(obj);
+ int flag = 0;
+ String[] emp=null;
+ while (reader.hasNextLine()) {
+ String data = reader.nextLine();
+// System.out.println(data);
+ emp = data.split(",");
+ Employee employee = new Employee(emp[0],emp[1],emp[2],emp[3]);
+ employees.add(employee);
+ }
+ System.out.println("Enter A for Ascending and D for Descending :");
+ Scanner sc = new Scanner(System.in);
+ String order = sc.next();
+ if (orderBy.equalsIgnoreCase("name")){
+ if (order.equalsIgnoreCase("A"))
+ Collections.sort(employees,new NameComparator());
+ else if (order.equalsIgnoreCase("D")){
+ Collections.sort(employees,new NameComparatorDesc());
+ }
+ else {
+ System.out.println("Invalid Input");
+ }
+ }
+ else if (orderBy.equalsIgnoreCase("Age")){
+ if (order.equalsIgnoreCase("A")){
+ Collections.sort(employees,new AgeComparator());
+ }
+
+ else if(order.equalsIgnoreCase("D")){
+ Collections.sort(employees,new AgeComparatorDesc());
+ }
+ else {
+ System.out.println("Invalid input");
+ }
+ }
+ else if (orderBy.equalsIgnoreCase("Email")){
+ if (order.equalsIgnoreCase("A")){
+ Collections.sort(employees,new EmailComparator());
+ }
+
+ else if(order.equalsIgnoreCase("D")){
+ Collections.sort(employees,new EmailComparatorDesc());
+ }
+ else {
+ System.out.println("Invalid input");
+ }
+ }
+ else if(orderBy.equalsIgnoreCase("Dob")){
+ if (order.equalsIgnoreCase("A")){
+ Collections.sort(employees,new DobComparator());
+ }
+
+ else if(order.equalsIgnoreCase("D")){
+ Collections.sort(employees,new DobComparatorDesc());
+ }
+ else {
+ System.out.println("Invalid input");
+ }
+
+ }
+ else {
+ System.out.println("Invalid input");
+ }
+//
+//
+
+ int k;
+ for(k=0;k