Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added out/production/Assignment1/com/company/Circle.class
Binary file not shown.
Binary file not shown.
Binary file added out/production/Assignment1/com/company/Main.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added out/production/Assignment1/com/company/Sphere.class
Binary file not shown.
Binary file added out/production/Assignment1/com/company/Square.class
Binary file not shown.
Binary file not shown.
8 changes: 0 additions & 8 deletions src/com/company/Main.java

This file was deleted.

184 changes: 184 additions & 0 deletions src/com/hotwax/www/Main.java
Original file line number Diff line number Diff line change
@@ -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");
}

}
}
}
68 changes: 68 additions & 0 deletions src/com/hotwax/www/Problem_statement_1.java
Original file line number Diff line number Diff line change
@@ -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<String> 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<String, Integer> 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<String, Integer> sortedMap = new LinkedHashMap<>();
ArrayList<Integer> list = new ArrayList<>();
for (Map.Entry<String, Integer> entry : map.entrySet()) {
list.add(entry.getValue());
}
Collections.sort(list, Collections.reverseOrder());
for (int num : list) {
for (Entry<String, Integer> 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();
}
}
}
1 change: 1 addition & 0 deletions url.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://docs.oracle.com/en/java/
3 changes: 3 additions & 0 deletions words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Java
Oracle
information