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/company/Main.java b/src/com/company/Main.java deleted file mode 100644 index d9d1a8b..0000000 --- a/src/com/company/Main.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.company; - -public class Main { - - public static void main(String[] args) { - // write your code here - } -} 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..e6709fd --- /dev/null +++ b/src/com/hotwax/www/Problem_statement_1.java @@ -0,0 +1,68 @@ +package com.hotwax.www; +import java.io.*; +import java.net.URL; +import java.util.*; +import java.util.Map.Entry; + +public class Problem_statement_1 { + public static void main(String[] args) { +// String[] a = new String[3]; + ArrayList a = new ArrayList<>(); + try { + File obj1 = new File("url.txt"); + Scanner r = new Scanner(obj1); + File file = new File("words.txt"); + Scanner sc = new Scanner(file); + while (sc.hasNextLine()){ + a.add(sc.nextLine()); + } + Collections.sort(a); + 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; + HashMap map = new HashMap<>(); + int count=0; + int count1=0; + int count2=0; + while ((inputLine = in.readLine()) != null) { + + String result = inputLine.replaceAll("<[^>]*>", ""); + count = (result.split(a.get(0)).length) - 1; + count1 = (result.split(a.get(1)).length) - 1; + count2 = (result.split(a.get(2)).length) - 1; + v += count; + w += count1; + y += count2; + } + map.put(a.get(0),v); + map.put(a.get(1),w); + map.put(a.get(2),y); + System.out.println("For the url : " + x); + LinkedHashMap sortedMap = new LinkedHashMap<>(); + ArrayList list = new ArrayList<>(); + for (Map.Entry entry : map.entrySet()) { + list.add(entry.getValue()); + } + Collections.sort(list, Collections.reverseOrder()); + for (int num : list) { + for (Entry entry : map.entrySet()) { + if (entry.getValue().equals(num)) { + sortedMap.put(entry.getKey(), num); + } + } + } + System.out.println(sortedMap); + + in.close(); + } + r.close(); + } + catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/url.txt b/url.txt new file mode 100644 index 0000000..f4c4ce9 --- /dev/null +++ b/url.txt @@ -0,0 +1 @@ +https://docs.oracle.com/en/java/ diff --git a/words.txt b/words.txt new file mode 100644 index 0000000..7a5aaf4 --- /dev/null +++ b/words.txt @@ -0,0 +1,3 @@ +Java +Oracle +information