diff --git a/html/_Basics/01-skeleton (Basic Javascript Animation).html b/html/_Basics/01-skeleton (Basic Javascript Animation).html deleted file mode 100644 index ecfce13..0000000 --- a/html/_Basics/01-skeleton (Basic Javascript Animation).html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - diff --git a/html/_Basics/02-event-demo (Basic Javascript Animation).html b/html/_Basics/02-event-demo (Basic Javascript Animation).html deleted file mode 100644 index e8aa6cf..0000000 --- a/html/_Basics/02-event-demo (Basic Javascript Animation).html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - Event Demo - - - -
- Example from Foundation HTML5 Animation with JavaScript -
- - - - - - diff --git a/html/_Basics/03-mouse-events (Basic Javascript Animation).html b/html/_Basics/03-mouse-events (Basic Javascript Animation).html deleted file mode 100644 index 0121302..0000000 --- a/html/_Basics/03-mouse-events (Basic Javascript Animation).html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - Mouse Events - - - -
- Example from Foundation HTML5 Animation with JavaScript -
- - - - - - diff --git a/html/_Basics/04-mouse-position (Basic Javascript Animation).html b/html/_Basics/04-mouse-position (Basic Javascript Animation).html deleted file mode 100644 index 0b2dadc..0000000 --- a/html/_Basics/04-mouse-position (Basic Javascript Animation).html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - Mouse Position - - - -
- Example from Foundation HTML5 Animation with JavaScript -
- - - - - - - diff --git a/html/_Basics/05-touch-events (Basic Javascript Animation).html b/html/_Basics/05-touch-events (Basic Javascript Animation).html deleted file mode 100644 index 8eed4c6..0000000 --- a/html/_Basics/05-touch-events (Basic Javascript Animation).html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Touch Events - - - - -
- Example from Foundation HTML5 Animation with JavaScript -
- - - - - - diff --git a/html/_Basics/06-keyboard-events (Basic Javascript Animation).html b/html/_Basics/06-keyboard-events (Basic Javascript Animation).html deleted file mode 100644 index d519ca8..0000000 --- a/html/_Basics/06-keyboard-events (Basic Javascript Animation).html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Keyboard Events - - - -
- Example from Foundation HTML5 Animation with JavaScript -
- - - - - diff --git a/html/_Basics/07-key-codes (Basic Javascript Animation).html b/html/_Basics/07-key-codes (Basic Javascript Animation).html deleted file mode 100644 index e094d5b..0000000 --- a/html/_Basics/07-key-codes (Basic Javascript Animation).html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - Key Codes - - - -
- Example from Foundation HTML5 Animation with JavaScript -
- - - - - diff --git a/html/_Basics/08-key-names (Basic Javascript Animation).html b/html/_Basics/08-key-names (Basic Javascript Animation).html deleted file mode 100644 index d41236b..0000000 --- a/html/_Basics/08-key-names (Basic Javascript Animation).html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Key Names - - - -
- Example from Foundation HTML5 Animation with JavaScript -
- - - - - - diff --git a/html/_Basics/A simple HTML document.html b/html/_Basics/A simple HTML document.html deleted file mode 100644 index 3508585..0000000 --- a/html/_Basics/A simple HTML document.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - Simple HTML document - - -

Hello World!

- - \ No newline at end of file diff --git a/html/_Basics/Abbreviations and acronyms.html b/html/_Basics/Abbreviations and acronyms.html deleted file mode 100644 index e99bb99..0000000 --- a/html/_Basics/Abbreviations and acronyms.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - Example of HTML abbreviations - - -

The HTML is the publishing language of the World Wide Web.

-

The HTML is the publishing language of the World Wide Web.

-

Warning: The <acronym> tag has been removed in HTML5 and shouldn't be used anymore. Use the <abbr> tag instead.

- - \ No newline at end of file diff --git a/html/_Basics/Aligning images.html b/html/_Basics/Aligning images.html deleted file mode 100644 index ec0d946..0000000 --- a/html/_Basics/Aligning images.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Example image alignment - - -

This image Smiley is aligned vertically top of the text.

-

This image Smiley is aligned vertically center of the text.

-

This image Smiley is aligned to the baseline of the text.

- - \ No newline at end of file diff --git a/html/_Basics/Apply transformation while rendering text on web pages using SVG.html b/html/_Basics/Apply transformation while rendering text on web pages using SVG.html deleted file mode 100644 index 3f2f357..0000000 --- a/html/_Basics/Apply transformation while rendering text on web pages using SVG.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - -Rotate and Render Text with HTML5 SVG - - - - - - - Welcome to Our Website! - - - Here you will find lots of useful information. - - - - - \ No newline at end of file diff --git a/html/_Basics/Checkboxes and radio buttons.html b/html/_Basics/Checkboxes and radio buttons.html deleted file mode 100644 index 0c0b1dd..0000000 --- a/html/_Basics/Checkboxes and radio buttons.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Example of HTML checkboxes and radio buttons - - -
-
- Hobbies - - - - - - -
-
- Gender - - - - -
-
- - \ No newline at end of file diff --git a/html/_Basics/Column groups - The col and colgroup elements.html b/html/_Basics/Column groups - The col and colgroup elements.html deleted file mode 100644 index f11defd..0000000 --- a/html/_Basics/Column groups - The col and colgroup elements.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - Example of HTML table column groups - - - - - - - - - - - - - - - -
row 1, cell 1row 1, cell 2
row 2, cell 1row 2, cell 2
- - \ No newline at end of file diff --git a/html/_Basics/Computer output tags.html b/html/_Basics/Computer output tags.html deleted file mode 100644 index ca82192..0000000 --- a/html/_Basics/Computer output tags.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Example of HTML computer output tags - - -

Computer code

-

Keyboard input

-

Sample text

-

Computer variable

-

Note: These tags are often used to represents a fragment of computer code.

- - \ No newline at end of file diff --git a/html/_Basics/Create hyperlink.html b/html/_Basics/Create hyperlink.html deleted file mode 100644 index 8ffea09..0000000 --- a/html/_Basics/Create hyperlink.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - Example of HTML a tag - - -

Tutorial Republic

-

Hot Air Ballons

-

Google Search

- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 color input type.html b/html/_Basics/Creating HTML5 color input type.html deleted file mode 100644 index 4918cbf..0000000 --- a/html/_Basics/Creating HTML5 color input type.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -HTML5 Color Input Type - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 date input type.html b/html/_Basics/Creating HTML5 date input type.html deleted file mode 100644 index 5e3c9fa..0000000 --- a/html/_Basics/Creating HTML5 date input type.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -HTML5 Date Input Type - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 datetime input type.html b/html/_Basics/Creating HTML5 datetime input type.html deleted file mode 100644 index be0df4f..0000000 --- a/html/_Basics/Creating HTML5 datetime input type.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -HTML5 Datetime Input Type - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 datetime-local input type.html b/html/_Basics/Creating HTML5 datetime-local input type.html deleted file mode 100644 index 8c8bc12..0000000 --- a/html/_Basics/Creating HTML5 datetime-local input type.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -HTML5 Datetime-local Input Type - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 email input type.html b/html/_Basics/Creating HTML5 email input type.html deleted file mode 100644 index f3e7757..0000000 --- a/html/_Basics/Creating HTML5 email input type.html +++ /dev/null @@ -1,21 +0,0 @@ - - - -HTML5 Email Input Type - - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 month input type.html b/html/_Basics/Creating HTML5 month input type.html deleted file mode 100644 index ccf12ca..0000000 --- a/html/_Basics/Creating HTML5 month input type.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -HTML5 Month Input Type - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 number input type.html b/html/_Basics/Creating HTML5 number input type.html deleted file mode 100644 index 168772b..0000000 --- a/html/_Basics/Creating HTML5 number input type.html +++ /dev/null @@ -1,22 +0,0 @@ - - - -HTML5 Number Input Type - - - -
- -
-

Note: If you try to enter the number out of the range (1-10) or text character it will show error.

- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 range input type.html b/html/_Basics/Creating HTML5 range input type.html deleted file mode 100644 index dca69e3..0000000 --- a/html/_Basics/Creating HTML5 range input type.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -HTML5 Range Input Type - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 search input type.html b/html/_Basics/Creating HTML5 search input type.html deleted file mode 100644 index ef3141e..0000000 --- a/html/_Basics/Creating HTML5 search input type.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -HTML5 Search Input Type - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 tel input type.html b/html/_Basics/Creating HTML5 tel input type.html deleted file mode 100644 index 09826ed..0000000 --- a/html/_Basics/Creating HTML5 tel input type.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -HTML5 Tel Input Type - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 time input type.html b/html/_Basics/Creating HTML5 time input type.html deleted file mode 100644 index c57b906..0000000 --- a/html/_Basics/Creating HTML5 time input type.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -HTML5 Time Input Type - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 url input type.html b/html/_Basics/Creating HTML5 url input type.html deleted file mode 100644 index 059d657..0000000 --- a/html/_Basics/Creating HTML5 url input type.html +++ /dev/null @@ -1,22 +0,0 @@ - - - -HTML5 URL Input Type - - - -
- -
-

Note: Enter URL in the form like http://www.google.com

- - \ No newline at end of file diff --git a/html/_Basics/Creating HTML5 week input type.html b/html/_Basics/Creating HTML5 week input type.html deleted file mode 100644 index abafec2..0000000 --- a/html/_Basics/Creating HTML5 week input type.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -HTML5 Week Input Type - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating a circle using SVG.html b/html/_Basics/Creating a circle using SVG.html deleted file mode 100644 index bbfe5fc..0000000 --- a/html/_Basics/Creating a circle using SVG.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - -Create a Circle with HTML5 SVG - - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Creating a definition list.html b/html/_Basics/Creating a definition list.html deleted file mode 100644 index 9edffa1..0000000 --- a/html/_Basics/Creating a definition list.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Example of HTML Definition List - - -

HTML Definition List

-
-
Bread
-
A baked food made of flour.
-
Coffee
-
A drink made from roasted coffee beans.
-
- - \ No newline at end of file diff --git a/html/_Basics/Creating a line using SVG.html b/html/_Basics/Creating a line using SVG.html deleted file mode 100644 index cbc3bd3..0000000 --- a/html/_Basics/Creating a line using SVG.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - -Create a Line with HTML5 SVG - - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Creating a mailto link - A link that sends an e-mail.html b/html/_Basics/Creating a mailto link - A link that sends an e-mail.html deleted file mode 100644 index becc859..0000000 --- a/html/_Basics/Creating a mailto link - A link that sends an e-mail.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Example of HTML email link - - -

This is an email link: - Send Mail -

-

Note: Spaces between words should be replaced by %20 to ensure that the browser will display the text correctly.

- - \ No newline at end of file diff --git a/html/_Basics/Creating a nested list - Multi level.html b/html/_Basics/Creating a nested list - Multi level.html deleted file mode 100644 index a31ae8f..0000000 --- a/html/_Basics/Creating a nested list - Multi level.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - Example of HTML nested list - - -

HTML Nested List

- - - \ No newline at end of file diff --git a/html/_Basics/Creating a nested list - Single level.html b/html/_Basics/Creating a nested list - Single level.html deleted file mode 100644 index 1ae3e6d..0000000 --- a/html/_Basics/Creating a nested list - Single level.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - Example of HTML nested list - - -

HTML Nested List

- - - \ No newline at end of file diff --git a/html/_Basics/Creating a rectangle using SVG.html b/html/_Basics/Creating a rectangle using SVG.html deleted file mode 100644 index 41ff664..0000000 --- a/html/_Basics/Creating a rectangle using SVG.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - -Create a Rectangle with HTML5 SVG - - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Creating an image-map - An image with clickable regions.html b/html/_Basics/Creating an image-map - An image with clickable regions.html deleted file mode 100644 index c64d65d..0000000 --- a/html/_Basics/Creating an image-map - An image with clickable regions.html +++ /dev/null @@ -1,16 +0,0 @@ - - - -Example of HTML image map - - -

Click on a shape to see how it works:

- Geometrical Shapes - - Circle - Triangle - Rectangle - Pentagon - - - \ No newline at end of file diff --git a/html/_Basics/Creating an ordered list.html b/html/_Basics/Creating an ordered list.html deleted file mode 100644 index 4aa351e..0000000 --- a/html/_Basics/Creating an ordered list.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Example of HTML Ordered List - - -

HTML Ordered List

-
    -
  1. Mix ingredients
  2. -
  3. Bake in oven for an hour
  4. -
  5. Allow to stand for ten minutes
  6. -
- - \ No newline at end of file diff --git a/html/_Basics/Creating an unordered list.html b/html/_Basics/Creating an unordered list.html deleted file mode 100644 index e9e7813..0000000 --- a/html/_Basics/Creating an unordered list.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Example of HTML Unordered List - - -

HTML Unordered List

- - - \ No newline at end of file diff --git a/html/_Basics/Creating buttons.html b/html/_Basics/Creating buttons.html deleted file mode 100644 index c753bd2..0000000 --- a/html/_Basics/Creating buttons.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - Example of HTML button - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Creating links to other HTML documents or Web resources.html b/html/_Basics/Creating links to other HTML documents or Web resources.html deleted file mode 100644 index 77af77f..0000000 --- a/html/_Basics/Creating links to other HTML documents or Web resources.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - Example of HTML Links - - -

Tutorial Republic

-

kites

-

Google Search

- - \ No newline at end of file diff --git a/html/_Basics/Creating password input fields.html b/html/_Basics/Creating password input fields.html deleted file mode 100644 index 29e46bf..0000000 --- a/html/_Basics/Creating password input fields.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Example of HTML Password Field - - - -
- - -
- - \ No newline at end of file diff --git a/html/_Basics/Creating text input fields.html b/html/_Basics/Creating text input fields.html deleted file mode 100644 index 475adc8..0000000 --- a/html/_Basics/Creating text input fields.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Example of HTML Text Field - - -
- - -
- - \ No newline at end of file diff --git a/html/_Basics/Defining alternative sources for audio element.html b/html/_Basics/Defining alternative sources for audio element.html deleted file mode 100644 index 7aad6c2..0000000 --- a/html/_Basics/Defining alternative sources for audio element.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - The HTML5 audio Element - - - - - \ No newline at end of file diff --git a/html/_Basics/Defining alternative sources for video element.html b/html/_Basics/Defining alternative sources for video element.html deleted file mode 100644 index bec6cf9..0000000 --- a/html/_Basics/Defining alternative sources for video element.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Example of Inserting Video Using object Element - - - - - \ No newline at end of file diff --git a/html/_Basics/Drawing a circle onto the canvas.html b/html/_Basics/Drawing a circle onto the canvas.html deleted file mode 100644 index a9aad9a..0000000 --- a/html/_Basics/Drawing a circle onto the canvas.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - -Drawing a Circle on Canvas - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Drawing a line onto the canvas.html b/html/_Basics/Drawing a line onto the canvas.html deleted file mode 100644 index b301df3..0000000 --- a/html/_Basics/Drawing a line onto the canvas.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - -Drawing a Line on Canvas - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Drawing a rectangle onto the canvas.html b/html/_Basics/Drawing a rectangle onto the canvas.html deleted file mode 100644 index 0d03dba..0000000 --- a/html/_Basics/Drawing a rectangle onto the canvas.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - -Drawing a Rectangle on Canvas - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Drawing an arc onto the canvas.html b/html/_Basics/Drawing an arc onto the canvas.html deleted file mode 100644 index b6e0fde..0000000 --- a/html/_Basics/Drawing an arc onto the canvas.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - -Drawing an Arc on Canvas - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Embedding SVG into HTML documents.html b/html/_Basics/Embedding SVG into HTML documents.html deleted file mode 100644 index f5b86eb..0000000 --- a/html/_Basics/Embedding SVG into HTML documents.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - -Embedding SVG Into HTML Pages - - - - - Your browser support SVG. - - Sorry, your browser does not support SVG. - - - \ No newline at end of file diff --git a/html/_Basics/Embedding audio in HTML documents.html b/html/_Basics/Embedding audio in HTML documents.html deleted file mode 100644 index 00e69c3..0000000 --- a/html/_Basics/Embedding audio in HTML documents.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - The HTML5 audio Element - - - - - \ No newline at end of file diff --git a/html/_Basics/Embedding canvas into HTML documents.html b/html/_Basics/Embedding canvas into HTML documents.html deleted file mode 100644 index 21bb886..0000000 --- a/html/_Basics/Embedding canvas into HTML documents.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - -HTML5 Canvas - - - - - - \ No newline at end of file diff --git a/html/_Basics/Embedding the YouTube video in HTML documents.html b/html/_Basics/Embedding the YouTube video in HTML documents.html deleted file mode 100644 index b296e46..0000000 --- a/html/_Basics/Embedding the YouTube video in HTML documents.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - The HTML5 video element - - - - - \ No newline at end of file diff --git a/html/_Basics/Embedding video in HTML documents.html b/html/_Basics/Embedding video in HTML documents.html deleted file mode 100644 index eaffa6e..0000000 --- a/html/_Basics/Embedding video in HTML documents.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - The HTML5 video element - - - - - \ No newline at end of file diff --git a/html/_Basics/Enable multiple selection inside a select box.html b/html/_Basics/Enable multiple selection inside a select box.html deleted file mode 100644 index 1b3b77c..0000000 --- a/html/_Basics/Enable multiple selection inside a select box.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - Example of HTML select box with multiple selection - - -
- -
-

Note: Press control or shift key on the keyboard while clicking on the other options to enable multiple selections.

- - \ No newline at end of file diff --git a/html/_Basics/File select field.html b/html/_Basics/File select field.html deleted file mode 100644 index 1476b44..0000000 --- a/html/_Basics/File select field.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Example of file select form control - - -
- - -
- - \ No newline at end of file diff --git a/html/_Basics/Filling color inside a circular shape on canvas.html b/html/_Basics/Filling color inside a circular shape on canvas.html deleted file mode 100644 index 6ade4c4..0000000 --- a/html/_Basics/Filling color inside a circular shape on canvas.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - -Example of Filling Color inside a Circle - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Filling color inside a rectangle shape on canvas.html b/html/_Basics/Filling color inside a rectangle shape on canvas.html deleted file mode 100644 index 8e9c80e..0000000 --- a/html/_Basics/Filling color inside a rectangle shape on canvas.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - -Example of Filling Color inside a Rectangle - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Filling linear gradient inside canvas shapes.html b/html/_Basics/Filling linear gradient inside canvas shapes.html deleted file mode 100644 index 9d37c17..0000000 --- a/html/_Basics/Filling linear gradient inside canvas shapes.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -Example of Filling Linear Gradient inside Canvas Shapes - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Filling radial gradient inside canvas shapes.html b/html/_Basics/Filling radial gradient inside canvas shapes.html deleted file mode 100644 index 8e45e5c..0000000 --- a/html/_Basics/Filling radial gradient inside canvas shapes.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -Example of Filling Radial Gradient inside Canvas Shapes - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Grouping of options inside a select box.html b/html/_Basics/Grouping of options inside a select box.html deleted file mode 100644 index 86a2af8..0000000 --- a/html/_Basics/Grouping of options inside a select box.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - Example of HTML optgroup tag - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Grouping similar form fields.html b/html/_Basics/Grouping similar form fields.html deleted file mode 100644 index c193493..0000000 --- a/html/_Basics/Grouping similar form fields.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - Example of HTML fieldset tag - - -
-
- Gender - - - - -
-
- - \ No newline at end of file diff --git a/html/_Basics/Headings - h1 to h6.html b/html/_Basics/Headings - h1 to h6.html deleted file mode 100644 index de03ee6..0000000 --- a/html/_Basics/Headings - h1 to h6.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Example of HTML headings tag - - -

Heading level 1

-

Heading level 2

-

Heading level 3

-

Heading level 4

-
Heading level 5
-
Heading level 6
- - \ No newline at end of file diff --git a/html/_Basics/Insert contact information.html b/html/_Basics/Insert contact information.html deleted file mode 100644 index 7d62908..0000000 --- a/html/_Basics/Insert contact information.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - Example of HTML address tag (check) - - -
- Written by Jon Doe.
- Contact us at:
- Post Box 210, Hollywood
- USA -
- - \ No newline at end of file diff --git a/html/_Basics/Inserting audio in HTML documents using the embed element.html b/html/_Basics/Inserting audio in HTML documents using the embed element.html deleted file mode 100644 index 21b8485..0000000 --- a/html/_Basics/Inserting audio in HTML documents using the embed element.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Example of Inserting Audio Using object Element - - - - - - \ No newline at end of file diff --git a/html/_Basics/Inserting audio in HTML documents using the object element.html b/html/_Basics/Inserting audio in HTML documents using the object element.html deleted file mode 100644 index 21b8485..0000000 --- a/html/_Basics/Inserting audio in HTML documents using the object element.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Example of Inserting Audio Using object Element - - - - - - \ No newline at end of file diff --git a/html/_Basics/Inserting comments.html b/html/_Basics/Inserting comments.html deleted file mode 100644 index f2e899d..0000000 --- a/html/_Basics/Inserting comments.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Example of HTML comments - - - - -

This is a heading

-

This is a paragraph.

- - \ No newline at end of file diff --git a/html/_Basics/Inserting horizontal lines.html b/html/_Basics/Inserting horizontal lines.html deleted file mode 100644 index 292beb3..0000000 --- a/html/_Basics/Inserting horizontal lines.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - Example of HTML hr tag - - -

This is the first paragraph of text.

-
-

This is second paragraph of text.

- - \ No newline at end of file diff --git a/html/_Basics/Inserting images into the HTML document.html b/html/_Basics/Inserting images into the HTML document.html deleted file mode 100644 index 2fae3ed..0000000 --- a/html/_Basics/Inserting images into the HTML document.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - Example of HTML Images - - -
- Flying Kites - Cloudy Sky - Hot Air Balloons -
- - \ No newline at end of file diff --git a/html/_Basics/Inserting paragraphs of text content.html b/html/_Basics/Inserting paragraphs of text content.html deleted file mode 100644 index 96996d1..0000000 --- a/html/_Basics/Inserting paragraphs of text content.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Example of HTML Paragraphs - - -

This is a paragraph.

-

This is another paragraph.

- - \ No newline at end of file diff --git a/html/_Basics/Inserting video in HTML documents using the embed element.html b/html/_Basics/Inserting video in HTML documents using the embed element.html deleted file mode 100644 index d7f71f3..0000000 --- a/html/_Basics/Inserting video in HTML documents using the embed element.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Example of Embedding a YouTube Video - - - -

Source: http://www.youtube.com/watch?v=YE7VzlLtp-4

- - \ No newline at end of file diff --git a/html/_Basics/Inserting video in HTML documents using the object element.html b/html/_Basics/Inserting video in HTML documents using the object element.html deleted file mode 100644 index d739bdf..0000000 --- a/html/_Basics/Inserting video in HTML documents using the object element.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Example of Inserting Video Using embed Element - - - - - \ No newline at end of file diff --git a/html/_Basics/Linking the audio files.html b/html/_Basics/Linking the audio files.html deleted file mode 100644 index 6d148e2..0000000 --- a/html/_Basics/Linking the audio files.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Example of Linking Audio Files - - -

Track 1

-

Track 2

- - \ No newline at end of file diff --git a/html/_Basics/Long and short quotations.html b/html/_Basics/Long and short quotations.html deleted file mode 100644 index 18dbe4b..0000000 --- a/html/_Basics/Long and short quotations.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Example of HTML quotations - - -
-

This is an example of a long quotation.

-
-

This is an example of short inline quotation.

- - \ No newline at end of file diff --git a/html/_Basics/Make a hyperlink of an image.html b/html/_Basics/Make a hyperlink of an image.html deleted file mode 100644 index 9a8db12..0000000 --- a/html/_Basics/Make a hyperlink of an image.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - Example of linking images - - -

Hot Air Ballons

- - \ No newline at end of file diff --git a/html/_Basics/Making a simple table - The most basic form of a table.html b/html/_Basics/Making a simple table - The most basic form of a table.html deleted file mode 100644 index 03e22fe..0000000 --- a/html/_Basics/Making a simple table - The most basic form of a table.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - Example of HTML Table - - - - - - - - - - - - - - - - - - - - - - - - - - - -
No.NameEmail
1John Carterjohncarter@mail.com
2Peter Parkerpeterparker@mail.com
3John Rambojohnrambo@mail.com
- - \ No newline at end of file diff --git a/html/_Basics/Marking deleted and inserted text.html b/html/_Basics/Marking deleted and inserted text.html deleted file mode 100644 index fb3a256..0000000 --- a/html/_Basics/Marking deleted and inserted text.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - Example of HTML deleted and inserted text - - -

To Do

- - - \ No newline at end of file diff --git a/html/_Basics/Move outside of an iframe.html b/html/_Basics/Move outside of an iframe.html deleted file mode 100644 index c888b5d..0000000 --- a/html/_Basics/Move outside of an iframe.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - Example of moving outside of an iframe - - -

Want to move outside the iframe and go to the home page: Click here!

- - \ No newline at end of file diff --git a/html/_Basics/Navigate inside page - Jump link.html b/html/_Basics/Navigate inside page - Jump link.html deleted file mode 100644 index ac497a8..0000000 --- a/html/_Basics/Navigate inside page - Jump link.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - Example of jump link - - -

Jump Link

-

Maecenas non leo sed velit sodales scelerisque sed id felis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed tempus eros vitae lacus pulvinar faucibus. Aliquam erat volutpat. Nunc nec orci massa, a sagittis mi. Donec non arcu nec lacus bibendum varius. In pharetra diam ut mauris suscipit ac congue lectus fringilla. Cras vehicula elit in tortor luctus sodales. Etiam nunc sapien, consequat ac vulputate non, vulputate in sapien. Etiam arcu tortor, volutpat eu malesuada id, interdum laoreet tellus. Nulla eros est, semper in cursus a, elementum ac sem.

- - \ No newline at end of file diff --git a/html/_Basics/Open link in a new browser window.html b/html/_Basics/Open link in a new browser window.html deleted file mode 100644 index 54c705c..0000000 --- a/html/_Basics/Open link in a new browser window.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - Example of linking images - - -

W3C This is a link to a website on the World Wide Web.

- - \ No newline at end of file diff --git a/html/_Basics/Paragraph and line breaks.html b/html/_Basics/Paragraph and line breaks.html deleted file mode 100644 index 38bec41..0000000 --- a/html/_Basics/Paragraph and line breaks.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Example of Inserting Line Breaks in HTML - - -

This is a paragraph
with line break.

-

This is
another paragraph
with line breaks.

- - \ No newline at end of file diff --git a/html/_Basics/Preformatted text (Preserve line breaks and spaces).html b/html/_Basics/Preformatted text (Preserve line breaks and spaces).html deleted file mode 100644 index 4932dc5..0000000 --- a/html/_Basics/Preformatted text (Preserve line breaks and spaces).html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Example of HTML pre tag - - -
-    The pre
-        element preserves      spaces,
-            line-breaks, tabs...
-    
- - \ No newline at end of file diff --git a/html/_Basics/Rendering text on web pages using SVG.html b/html/_Basics/Rendering text on web pages using SVG.html deleted file mode 100644 index 82b0b4e..0000000 --- a/html/_Basics/Rendering text on web pages using SVG.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - -Render Text with HTML5 SVG - - - - - - Welcome to Our Website! - - - Here you will find lots of useful information. - - - - \ No newline at end of file diff --git a/html/_Basics/Select box with a pre-selected value.html b/html/_Basics/Select box with a pre-selected value.html deleted file mode 100644 index b88b780..0000000 --- a/html/_Basics/Select box with a pre-selected value.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - Example of HTML select box - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Select boxes - A drop-down list.html b/html/_Basics/Select boxes - A drop-down list.html deleted file mode 100644 index b015b49..0000000 --- a/html/_Basics/Select boxes - A drop-down list.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - Example of HTML select box - - -
- -
- - \ No newline at end of file diff --git a/html/_Basics/Sets the distance between table cells - The cellspacing attribute.html b/html/_Basics/Sets the distance between table cells - The cellspacing attribute.html deleted file mode 100644 index b25715f..0000000 --- a/html/_Basics/Sets the distance between table cells - The cellspacing attribute.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - Example of HTML table cellspacing - - - - - - - - - - - - -
User Information
NameEmail
Johnjohn@mail.com
-

Note: The CSS margin property is the better way to control spacing between table cells.

- - \ No newline at end of file diff --git a/html/_Basics/Sets the padding of table cells - The cellpadding attribute.html b/html/_Basics/Sets the padding of table cells - The cellpadding attribute.html deleted file mode 100644 index 067d1eb..0000000 --- a/html/_Basics/Sets the padding of table cells - The cellpadding attribute.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - Example of HTML table cellpadding - - - - - - - - - - - - -
User Information
NameEmail
Johnjohn@mail.com
-

Note: The CSS padding property is the better way to control paddings of table cells.

- - \ No newline at end of file diff --git a/html/_Basics/Setting text direction of an element.html b/html/_Basics/Setting text direction of an element.html deleted file mode 100644 index 1feb239..0000000 --- a/html/_Basics/Setting text direction of an element.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - Example of HTML bdo tag - - -

The sequence "1-2-3-4-5" was reversed as: 1-2-3-4-5

- - \ No newline at end of file diff --git a/html/_Basics/Setting the cap style for the stroke on canvas.html b/html/_Basics/Setting the cap style for the stroke on canvas.html deleted file mode 100644 index 18f8052..0000000 --- a/html/_Basics/Setting the cap style for the stroke on canvas.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - -Example of Setting Stroke Cap Style - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Setting the dimension of a table.html b/html/_Basics/Setting the dimension of a table.html deleted file mode 100644 index 3a90578..0000000 --- a/html/_Basics/Setting the dimension of a table.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - Example of setting HTML table dimensions - - - - - - - - - - - -
row 1, cell 1row 1, cell 2
row 2, cell 1row 2, cell 2
-

Note: The CSS width and height property is the better way to set dimensions of a table.

- - \ No newline at end of file diff --git a/html/_Basics/Setting the stroke color and width on canvas.html b/html/_Basics/Setting the stroke color and width on canvas.html deleted file mode 100644 index 87e288b..0000000 --- a/html/_Basics/Setting the stroke color and width on canvas.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - -Example of Setting Stroke Color and Width - - - - - - - \ No newline at end of file diff --git a/html/_Basics/Setting width and height of the images.html b/html/_Basics/Setting width and height of the images.html deleted file mode 100644 index 6c84b5b..0000000 --- a/html/_Basics/Setting width and height of the images.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - Example of Setting Dimensions for Images - - -
- Flying Kites - Cloudy Sky - Hot Air Balloons -
- - \ No newline at end of file diff --git a/html/_Basics/Specify headings for the content.html b/html/_Basics/Specify headings for the content.html deleted file mode 100644 index de03ee6..0000000 --- a/html/_Basics/Specify headings for the content.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Example of HTML headings tag - - -

Heading level 1

-

Heading level 2

-

Heading level 3

-

Heading level 4

-
Heading level 5
-
Heading level 6
- - \ No newline at end of file diff --git a/html/_Basics/Specify the table caption.html b/html/_Basics/Specify the table caption.html deleted file mode 100644 index 1715246..0000000 --- a/html/_Basics/Specify the table caption.html +++ /dev/null @@ -1,40 +0,0 @@ - - - -Example of HTML caption Tag - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
User Details
No.NameEmail
1John Carterjohncarter@mail.com
2Peter Parkerpeterparker@mail.com
3John Rambojohnrambo@mail.com
- - \ No newline at end of file diff --git a/html/_Basics/Sub and Superscript text.html b/html/_Basics/Sub and Superscript text.html deleted file mode 100644 index bbb9b95..0000000 --- a/html/_Basics/Sub and Superscript text.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - Example of HTML subscript and superscript - - -

The chemical formula of Water is: H2O

-

The chemical formula of Carbon Dioxide is: CO2

-

The equation of mass-energy equivalence is: E=mc2

- - \ No newline at end of file diff --git a/html/_Basics/Submit or reset a form - The use of submit and reset button.html b/html/_Basics/Submit or reset a form - The use of submit and reset button.html deleted file mode 100644 index c794337..0000000 --- a/html/_Basics/Submit or reset a form - The use of submit and reset button.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - Example of HTML Submit and Reset Buttons - - -
- - - - -
- - \ No newline at end of file diff --git a/html/_Basics/Table cells that span more than one rowcolumn - The rowspancolspan attribute.html b/html/_Basics/Table cells that span more than one rowcolumn - The rowspancolspan attribute.html deleted file mode 100644 index 33c6fe4..0000000 --- a/html/_Basics/Table cells that span more than one rowcolumn - The rowspancolspan attribute.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - Example of HTML Table Rowspan and Colspan - - -

Example of Table Rowspan

- - - - - - - - - - - - - - - - - - - -
Users Info
1John Carterjohncarter@mail.com
2Peter Parkerpeterparker@mail.com
3John Rambojohnrambo@mail.com
-

Example of Table Colspan

- - - - - - - - - - - - - - - - - - - -
Users Info
1John Carterjohncarter@mail.com
2Peter Parkerpeterparker@mail.com
3John Rambojohnrambo@mail.com
- - \ No newline at end of file diff --git a/html/_Basics/Tables with borders - Adding the default table borders.html b/html/_Basics/Tables with borders - Adding the default table borders.html deleted file mode 100644 index f835e63..0000000 --- a/html/_Basics/Tables with borders - Adding the default table borders.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - Example of HTML tables default border - - - - - - - - - - - -
row 1, cell 1row 1, cell 2
row 2, cell 1row 2, cell 2
-

Note: The CSS border property is the better way to set borders for tables.

- - \ No newline at end of file diff --git a/html/_Basics/Text formatting.html b/html/_Basics/Text formatting.html deleted file mode 100644 index 096a601..0000000 --- a/html/_Basics/Text formatting.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - Example of HTML Paragraphs - - -

This text is bold

-

This is computer code

-

This text is emphasized

-

This text is italic

-

This text is small

-

This text is marked

-

This text is strongly emphasized

-

This is subscript and superscript

-

This text is inserted to the document

-

This text is deleted from the document

- - \ No newline at end of file diff --git a/html/_Basics/Textarea - A multi-line text input field.html b/html/_Basics/Textarea - A multi-line text input field.html deleted file mode 100644 index 81495f5..0000000 --- a/html/_Basics/Textarea - A multi-line text input field.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Example of HTML From Textarea - - -
- - -
- - \ No newline at end of file diff --git a/html/_Basics/Using image as a link.html b/html/_Basics/Using image as a link.html deleted file mode 100644 index 9a8db12..0000000 --- a/html/_Basics/Using image as a link.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - Example of linking images - - -

Hot Air Ballons

- - \ No newline at end of file diff --git a/html/_Basics/blockquote.html b/html/_Basics/blockquote.html deleted file mode 100644 index 8fb91cb..0000000 --- a/html/_Basics/blockquote.html +++ /dev/null @@ -1,12 +0,0 @@ - - - -Html5 - - - -Seneca says:
-
Admire who tries,
-but fails
- - \ No newline at end of file diff --git a/html/_Basics/definition_list.html b/html/_Basics/definition_list.html deleted file mode 100644 index f5f987d..0000000 --- a/html/_Basics/definition_list.html +++ /dev/null @@ -1,17 +0,0 @@ - - - -Html5 - - - -
-
Term 1
-
Definition 1
-
Term 2
-
Definition 2
-
Term 3
-
Definition 3
-
- - \ No newline at end of file diff --git a/html/_Basics/drag-and-drop.html b/html/_Basics/drag-and-drop.html deleted file mode 100644 index 5ebea80..0000000 --- a/html/_Basics/drag-and-drop.html +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Drag and Drop - - - -

Drag and Drop

- -

- - - -

- -
Drag Me!
- -
Drop Here!
- - - - - - \ No newline at end of file diff --git a/html/_Basics/drag-handle.html b/html/_Basics/drag-handle.html deleted file mode 100644 index 1e3cb75..0000000 --- a/html/_Basics/drag-handle.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - Drag Handle - - - -

Drag Handle

- -
-
-
-
- - - - - \ No newline at end of file diff --git a/html/_Basics/draggable.html b/html/_Basics/draggable.html deleted file mode 100644 index 2d3f58c..0000000 --- a/html/_Basics/draggable.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - Draggable - - - -

Draggable

- -
Drag Me!
- - - - \ No newline at end of file diff --git a/html/_Basics/home.html b/html/_Basics/home.html deleted file mode 100644 index c63d859..0000000 --- a/html/_Basics/home.html +++ /dev/null @@ -1,666 +0,0 @@ - - - -Amazon.in Associates Central - Home - - - - - - - - - - - - - - - -
- -
-
- -
- - - -
-
-
- - - -
-
-
- -
- -
-
-
-
-Total Fees -
-
-₹846.76 -
-
-Clicks -
-
-172 -
-
-
- -
-
-
-
-Summary for This Month -
- -
-
-
-
Total Items Shipped: -
3 -
Total Earnings: -
₹40.19 -
Total Ordered Items: -
3 -
Clicks -
73 -
Conversion: -
4.11% -
-Last update: Apr 14 2017 -
-
-Combined report for all tracking IDs -
-
- -
- -
-
- -
-
-
-
- Deal of the Day, Lightning Deals and more... -
-
-
-
- DYK5Prime -
-
- -
- - - - -
-
-
- -
-
-
-
-
-
-
-

- -What do you think? - -

-

-Do you have a suggestion or comment about Associates Central website? -Let us know. -

-
- - - - - - - - -
- - - - - \ No newline at end of file diff --git a/html/_Basics/kanban.html b/html/_Basics/kanban.html deleted file mode 100644 index b8140a9..0000000 --- a/html/_Basics/kanban.html +++ /dev/null @@ -1,162 +0,0 @@ - - - - - Kanban Board - - - -

Kanban Board

- -
-
-

To Do

-
Make Killer App
-
Retire!
-
-
-

Doing

-
Learn HTML5
-
-
-

Done

-
-
- - - - \ No newline at end of file diff --git a/html/_Basics/nested_list.html b/html/_Basics/nested_list.html deleted file mode 100644 index 281833b..0000000 --- a/html/_Basics/nested_list.html +++ /dev/null @@ -1,23 +0,0 @@ - - - -Html5 - - - -
    -
  1. Titles
  2. -
  3. Html5 lists - -
  4. -
  5. Html5 tables
  6. -
  7. Html5 forms
  8. -
- - \ No newline at end of file diff --git a/html/_Basics/paragraphs.html b/html/_Basics/paragraphs.html deleted file mode 100644 index a03da23..0000000 --- a/html/_Basics/paragraphs.html +++ /dev/null @@ -1,21 +0,0 @@ - - - -Html5 - - - -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod -tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, -quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo -consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse -cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non -proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod -tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, -quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo -consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse -cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non -proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

- - \ No newline at end of file diff --git a/html/_Basics/separators.html b/html/_Basics/separators.html deleted file mode 100644 index 14a54f7..0000000 --- a/html/_Basics/separators.html +++ /dev/null @@ -1,12 +0,0 @@ - - - -Html5 - - - -Chapter 1 -
-Chapter 2 - - \ No newline at end of file diff --git a/html/_Basics/sortable.html b/html/_Basics/sortable.html deleted file mode 100644 index 293ee1f..0000000 --- a/html/_Basics/sortable.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - - Sortable Lists - - - -

Sortable Lists

- - - - - - \ No newline at end of file diff --git a/html/_Basics/sorted_list.html b/html/_Basics/sorted_list.html deleted file mode 100644 index 0c46860..0000000 --- a/html/_Basics/sorted_list.html +++ /dev/null @@ -1,17 +0,0 @@ - - - -Html5 - - - -Html5 lists: -
    -
  1. Sorted lists
  2. -
  3. Unsorted lists
  4. -
  5. Nested lists
  6. -
  7. Definition lists
  8. -
  9. Menu lists
  10. -
- - \ No newline at end of file diff --git a/html/_Basics/title.html b/html/_Basics/title.html deleted file mode 100644 index 1f4d31b..0000000 --- a/html/_Basics/title.html +++ /dev/null @@ -1,15 +0,0 @@ - - - -Html5 - - - -

Title of level 1

-

Title of level 2

-

Title of level 3

-

Title of level 4

-
Title of level 5
-
Title of level 6
- - \ No newline at end of file diff --git a/html/_Basics/title_css.html b/html/_Basics/title_css.html deleted file mode 100644 index 32ecb44..0000000 --- a/html/_Basics/title_css.html +++ /dev/null @@ -1,16 +0,0 @@ - - - -Html5 - - - - -

Title of level 3

-

Title of level 3

- - - \ No newline at end of file diff --git a/html/_Basics/unsorted_list.html b/html/_Basics/unsorted_list.html deleted file mode 100644 index 838b380..0000000 --- a/html/_Basics/unsorted_list.html +++ /dev/null @@ -1,17 +0,0 @@ - - - -Html5 - - - -Html5 lists: - - - \ No newline at end of file diff --git a/java/_Basics/A Ball Moving round the window.java b/java/_Basics/A Ball Moving round the window.java deleted file mode 100644 index e572dd5..0000000 --- a/java/_Basics/A Ball Moving round the window.java +++ /dev/null @@ -1,153 +0,0 @@ -A Ball Moving round the window - -:/* - */ -import java.applet.*; -import java.awt.*; -public class screencircle2 extends Applet implements Runnable -{ - Thread t; - int i,j,k,l,flag=0,m,x1,y1,x2,y2,m1,x3,y3,m2,m3; - Color bg; - public void init() - { - } - public void start() - { - t=new Thread(this,"a"); - t.start(); - } - public void run() - { - paint1(); - } - public void paint1() - { - Graphics g=getGraphics(); - try - { - for(i=0;i<260;i++) - { - for(j=130;j<=260;j++) - { - g.setColor(Color.red); - g.fillOval(i,j,40,40); - Thread.sleep(50); - i=i+5; - j=j+5; - paint2(); - if(j>=260) - { - k=i; - l=j; - paint3(); - break; - } - } - } - } - catch(InterruptedException s) - { - //ShowStatus("error"); - } - } - public void paint3() - { - setBackground(Color.black); - Graphics h=getGraphics(); - try - { - for(x1=k;x1<=260;x1++) - { - for(y1=j;y1>1;y1--) - { - h.setColor(Color.red); - h.fillOval(x1,y1,40,40); - Thread.sleep(50); - x1=x1+6; - y1=y1-4; - paint2(); - if(x1>=260) - { - m=x1; - m1=y1; - paint4(); - } - } - } - } - catch(InterruptedException s1) - { - //ShowStatus("error"); - } - } - public void paint4() - { - Graphics h1=getGraphics(); - try - { - for(x2=m;x2>=40;x2--) - { - for(y2=m1;y2>=1;y1--) - { - h1.setColor(Color.red); - h1.fillOval(x2,y2,40,40); - Thread.sleep(50); - x2=x2-5; - y2=y2-6; - paint2(); - if(y2<=1) - { - m2=x2; - m3=y2; - paint5(); - } - } - } - } - catch(InterruptedException s1) - { - //ShowStatus("error"); - } - } - public void paint5() - { - setBackground(Color.black); - - Graphics h2=getGraphics(); - try - { - for(x3=m2;x3>=1;x3--) - { - for(y3=m3;y3<260;y3++) - { - h2.setColor(Color.red); - h2.fillOval(x3,y3,40,40); - Thread.sleep(50); - x3=x3-6; - y3=y3+4; - paint2(); - if(x3<=1) - { - m=x1; - m1=y1; - paint1(); - } - } - } - } - catch(InterruptedException s1) - { - //ShowStatus("error"); - } - } - - - public void paint2() - { - Graphics d=getGraphics(); - d.setColor(Color.white); - d.fillRect(0,0,300,300); - setBackground(Color.black); - } -} diff --git a/java/_Basics/Account application.java b/java/_Basics/Account application.java deleted file mode 100644 index 6e76e71..0000000 --- a/java/_Basics/Account application.java +++ /dev/null @@ -1,10 +0,0 @@ -Account application - -package com.ack.learning.examples.account; - -public class AccountApplication { - public static void main( String[] args ) { - DepositAccount acc = new DepositAccount(); - System.out.println( acc.getName() ); - } -} diff --git a/java/_Basics/Account this.java b/java/_Basics/Account this.java deleted file mode 100644 index e0bac64..0000000 --- a/java/_Basics/Account this.java +++ /dev/null @@ -1,23 +0,0 @@ -Account this - -package com.ack.learning.examples.account; - -public class AccountThis { - public AccountThis() { - System.out.println( "created an account object" ); - } - - public AccountThis( String name ) { - this(); - System.out.println( "created account with name " + name ); - } - - public AccountThis( String name, double amount ) { - this( name ); - System.out.println( "create account with amount " + amount ); - } - - public static void main( String[] args ) { - AccountThis hsbc = new AccountThis( "jerry", 25d ); - } -} diff --git a/java/_Basics/Account.java b/java/_Basics/Account.java deleted file mode 100644 index e2ea64c..0000000 --- a/java/_Basics/Account.java +++ /dev/null @@ -1,23 +0,0 @@ -Account - -package com.ack.learning.examples.account; - -public class Account { - public Account() { - System.out.println( "created an account object" ); - } - - public Account( String name ) { - System.out.println( "created account -> " + name ); - } - - public Account( String name, double amount ) { - System.out.println( "account " + name + " with " + amount ); - } - - public static void main( String[] args ) { - Account lloyds = new Account(); - Account tsg = new Account( "barry" ); - Account hsbc = new Account( "jerry", 25d ); - } -} diff --git a/java/_Basics/An interface.java b/java/_Basics/An interface.java deleted file mode 100644 index 13fdf85..0000000 --- a/java/_Basics/An interface.java +++ /dev/null @@ -1,57 +0,0 @@ -An interface - - - -public interface AnInterface { - // can define constants in interfaces - public static final int MAX_VALUE = 300; - - // but really use interfaces for declaring methods - public void aMethod(); - - public int anotherMethod( String hey ) throws Exception; - - public void yetAnotherMethod() throws Exception, ArithmeticException; -} - -class ImplementInterfaceClass implements AnInterface { - - public void aMethod() { - - } - - // note that methods are matched on formal parameter types and - // method name. - public int anotherMethod( String yep ) throws Exception { - // note that when you implement an interface, its constants - // are brought into the defining class's scope - if( true ) { - return MAX_VALUE; - } - else { - // however, best to always prefix constants with the defining - // class or interface for readability purposes - return AnInterface.MAX_VALUE; - } - } - - /** - * this causes a duplication definition of anotherMethod because - * the method signature only differs by the return type. In Java, - * if two method differ only by the return type they are the same method - * from an inheritance perspective - * - public String anotherMethod(String yep) throws Exception - { - return null; - } - */ - - // finally, you can selectively choose which exception to declare - // on the throws clause of the implementing method, here we choose to omit - // Exception - public void yetAnotherMethod() throws ArithmeticException { - - } - -} diff --git a/java/_Basics/ArithmeticProgression.java b/java/_Basics/ArithmeticProgression.java deleted file mode 100644 index f8c1b3a..0000000 --- a/java/_Basics/ArithmeticProgression.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jwetherell.algorithms.sequence; - -/** - * Compute the result of adding a sequence of numbers from N (startNumber) to N+X (startNumber+numberOfNumbersToCompute) - *

- * https://en.wikipedia.org/wiki/Arithmetic_progression - *
- * @author Justin Wetherell - */ -public class ArithmeticProgression { - - /** - * Compute the result of adding X (numberOfNumbersToCompute) together starting at N (startNumber). - *

- * e.g. result = N + (N+1) + (N+2) + (N+3) + ..... + (N+X) - */ - public static final long sequenceTotalUsingLoop(int startNumber, int numberOfNumbersToCompute) { - int start = startNumber; - int length = numberOfNumbersToCompute; - long result = 0L; - while (length > 0) { - result += start++; - length--; - } - return result; - } - - /** - * Compute the result of adding X (numberOfNumbersToCompute) together starting at N (startNumber) using triangular numbers. - *

- * e.g. result = N + (N+1) + (N+2) + (N+3) + ..... + (N+X)
- *
- * https://en.wikipedia.org/wiki/Triangular_number - */ - public static final long sequenceTotalUsingTriangularNumbers(int startNumber, int numberOfNumbersToCompute) { - // n*(n+1)/2 - final int start = startNumber; - final int length = numberOfNumbersToCompute; - - long result = length * (length + 1) / 2; - result += (start - 1) * length; - return result; - } -} diff --git a/java/_Basics/Armstrong (Java).java b/java/_Basics/Armstrong (Java).java deleted file mode 100644 index 05916ce..0000000 --- a/java/_Basics/Armstrong (Java).java +++ /dev/null @@ -1,19 +0,0 @@ -class ArmstrongExample -{ - public static void main(String[] args) - { - int c=0,a,temp; - int n=153;//It is the number to check armstrong - temp=n; - while(n>0) - { - a=n%10; - n=n/10; - c=c+(a*a*a); - } - if(temp==c) - System.out.println("armstrong number"); - else - System.out.println("Not armstrong number"); - } -} \ No newline at end of file diff --git a/java/_Basics/Arrays and collections.java b/java/_Basics/Arrays and collections.java deleted file mode 100644 index 536f83f..0000000 --- a/java/_Basics/Arrays and collections.java +++ /dev/null @@ -1,27 +0,0 @@ -Arrays and collections - - - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -public class ArraysAndCollections { - public static void main( String[] args ) { - // create a list of integers - List l = new LinkedList(); - for( int i = 1; i < 11; i++ ) { - l.add( new Integer( i ) ); - } - - // convert to array - Object[] integers = l.toArray(); - - // convert back to list - List ll = Arrays.asList( integers ); - - // output lists - System.out.println( l ); - System.out.println( ll ); - } -} diff --git a/java/_Basics/Arrays of arrays.java b/java/_Basics/Arrays of arrays.java deleted file mode 100644 index bb4f708..0000000 --- a/java/_Basics/Arrays of arrays.java +++ /dev/null @@ -1,32 +0,0 @@ -Arrays of arrays - - - -public class ArraysOfArrays { - public static void main( String[] args ) { - // creates an array of integer arrays - // note that the column sizes are jagged, that is, - // of different sizes - int[][] matrix = - { - {1, 2, 4}, - {2, 4}, - {5, 6, 7, 8, 9} - }; - - // cycle through the array, and output its contents - for( int i = 0; i < matrix.length; i++ ) { - for( int j = 0; j < matrix[i].length; j++ ) { - System.out.println( "matrix[" + i + "][" + j + "] = " + matrix[i][j] ); - } - } - - // specify array of strings - String[][] anotherMatrix = - { - {"hello"}, - new String[]{"hello", "world"}, /* note, embed new arrays here */ - {"the", "quick", "brown", "fox"}, /* note, comma can be added here */ - }; - } -} diff --git a/java/_Basics/BasicDateFormatting.java b/java/_Basics/BasicDateFormatting.java deleted file mode 100644 index d524f15..0000000 --- a/java/_Basics/BasicDateFormatting.java +++ /dev/null @@ -1,38 +0,0 @@ -BasicDateFormatting - -package com.ack.j2se.date; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; - -public class BasicDateFormatting { - public static void main( String[] args ) throws Exception { - // get today's date - Date today = Calendar.getInstance().getTime(); - - // create a short version date formatter - DateFormat shortFormatter - = SimpleDateFormat.getDateInstance( SimpleDateFormat.SHORT ); - - // create a long version date formatter - DateFormat longFormatter - = SimpleDateFormat.getDateInstance( SimpleDateFormat.LONG ); - - // create date time formatter, medium for day, long for time - DateFormat mediumFormatter - = SimpleDateFormat.getDateTimeInstance( SimpleDateFormat.MEDIUM, - SimpleDateFormat.LONG ); - - // use the formatters to output the dates - System.out.println( shortFormatter.format( today ) ); - System.out.println( longFormatter.format( today ) ); - System.out.println( mediumFormatter.format( today ) ); - - // convert form date -> text, and text -> date - String dateAsText = shortFormatter.format( today ); - Date textAsDate = shortFormatter.parse( dateAsText ); - System.out.println( textAsDate ); - } -} diff --git a/java/_Basics/BinaryConverter (Java).java b/java/_Basics/BinaryConverter (Java).java deleted file mode 100644 index 9704c81..0000000 --- a/java/_Basics/BinaryConverter (Java).java +++ /dev/null @@ -1,56 +0,0 @@ - -public class BinaryConverter -{ - - public static void main(String[] args) - { - for(int i = -5; i < 33; i++) - { - System.out.println(i + ": " + toBinary(i)); - System.out.println(i); - //always another way - System.out.println(i + ": " + Integer.toBinaryString(i)); - } - } - - /* - * pre: none - * post: returns a String with base10Num in base 2 - */ - public static String toBinary(int base10Num) - { - boolean isNeg = base10Num < 0; - base10Num = Math.abs(base10Num); - String result = ""; - while(base10Num > 1) - { - result = (base10Num % 2) + result; - base10Num /= 2; - } - assert base10Num == 0 || base10Num == 1 : "value is not <= 1: " + base10Num; - result = base10Num + result; - assert all0sAnd1s(result); - if( isNeg ) - result = "-" + result; - return result; - } - - /* - * pre: cal != null - * post: return true if val consists only of characters 1 and 0, false otherwise - */ - public static boolean all0sAnd1s(String val) - { - assert val != null : "Failed precondition all0sAnd1s. parameter cannot be null"; - boolean all = true; - int i = 0; - char c; - while(all && i < val.length()) - { - c = val.charAt(i); - all = c == '0' || c == '1'; - i++; - } - return all; - } -} diff --git a/java/_Basics/Break statements.java b/java/_Basics/Break statements.java deleted file mode 100644 index 8a651fd..0000000 --- a/java/_Basics/Break statements.java +++ /dev/null @@ -1,32 +0,0 @@ -Break statements - - - -public class BreakStatements { - public static void main( String[] args ) { - - /** - * break out of a loop here - */ - for( int i = 0; i < 10; i++ ) { - System.out.println( i ); - if( i == 5 ) { - break; - } - } - - /** - * note, break only breaks you out of the current loop - */ - for( int i = 0; i < 10; i++ ) { - for( int j = 0; j < 10; j++ ) { - if( i == j ) { - System.out.println( "breaking out with i = " + i ); - break; - } - } - } - - boolean doneGetOut = false; - } -} diff --git a/java/_Basics/BubbleSort (Java).java b/java/_Basics/BubbleSort (Java).java deleted file mode 100644 index 2983922..0000000 --- a/java/_Basics/BubbleSort (Java).java +++ /dev/null @@ -1,37 +0,0 @@ -public class BubbleSortExample -{ - static void bubbleSort(int[] arr) - { - int n = arr.length; - int temp = 0; - for(int i=0; i < n; i++) - { - for(int j=1; j < (n-i); j++) - { - if(arr[j-1] > arr[j]) - { - //swap elements - temp = arr[j-1]; - arr[j-1] = arr[j]; - arr[j] = temp; - } - } - } - } - public static void main(String[] args) - { - int arr[] = {3,60,35,2,45,320,5}; - System.out.println("Array Before Bubble Sort"); - for(int i=0; i < arr.length; i++) - { - System.out.print(arr[i] + " "); - } - System.out.println(); - bubbleSort(arr);//sorting array elements using bubble sort - System.out.println("Array After Bubble Sort"); - for(int i=0; i < arr.length; i++) - { - System.out.print(arr[i] + " "); - } - } -} \ No newline at end of file diff --git a/java/_Basics/CLock CAN TAlk REALLy.java b/java/_Basics/CLock CAN TAlk REALLy.java deleted file mode 100644 index f811b9d..0000000 --- a/java/_Basics/CLock CAN TAlk REALLy.java +++ /dev/null @@ -1,88 +0,0 @@ -CLock CAN TAlk REALLy - -import java.util.*; -public class CLockTAlk -{ - public static void main(String[]args) - { - // get current time and date - Calendar now = Calendar.getInstance(); - int hour = now.get(Calendar.HOUR_OF_DAY); - int minute = now.get(Calendar.MINUTE); - int month = now.get(Calendar.MONTH)+ 1; - int day = now.get(Calendar.DAY_OF_MONTH); - int year = now.get(Calendar.YEAR); - - // display gretting - if (hour < 12) - System.out.println("Good morning Sir! -Have you ate breakfast -yet?"); - else if (hour < 18) - System.out.println("Good afternoon Sir! -Have you ate lunch -yet?"); - else - System.out.println("Good evening Sir! -Have you ate dinner -yet?"); - - // begin time message by showing the minutes - System.out.print("It is"); - if (minute != 0) - { - System.out.print(" " + minute + " "); - System.out.print( (minute != 1) ? "minutes" : "minute"); - System.out.print(" past"); - } - - // display the hour - System.out.print(" "); - System.out.print( (hour > 12) ? (hour - 12) : hour ); - System.out.print(" 0'clock on "); - - // display the name of the month - switch (month) - { - case 1: - System.out.print("January"); - break; - case 2: - System.out.print("February"); - break; - case 3: - System.out.print("March"); - break; - case 4: - System.out.print("April"); - break; - case 5: - System.out.print("May"); - break; - case 6: - System.out.print("June"); - break; - case 7: - System.out.print("July"); - break; - case 8: - System.out.print("August"); - break; - case 9: - System.out.print("September"); - break; - case 10: - System.out.print("October"); - break; - case 11: - System.out.print("November"); - break; - case 12: - System.out.print("December"); - } - - // display the date and year - System.out.println(" " + day + ", " + year + "."); - } - -} diff --git a/java/_Basics/Calculating compound interest.java b/java/_Basics/Calculating compound interest.java deleted file mode 100644 index 8d517f2..0000000 --- a/java/_Basics/Calculating compound interest.java +++ /dev/null @@ -1,29 +0,0 @@ -Calculating compound interest - - import java.text.DecimalFormat; - import javax.swing.JOptionPane; - import javax.swing.JTextArea; - - public class Interest - { - public static void main( String args[] ) - { - double amount, principal = 1000.0, rate = .05; - - DecimalFormat precisionTwo = new DecimalFormat( "0.00" ); - JTextArea outputTextArea = new JTextArea( 11, 20 ); - - outputTextArea.append( "Year\tAmount on deposit\n" ); - - for ( int year = 1; year <= 10; year++ ) - { - amount = principal * Math.pow( 1.0 + rate, year ); - outputTextArea.append( year + "\t" + - precisionTwo.format( amount ) + "\n" ); - } - - JOptionPane.showMessageDialog( null, outputTextArea, "Compound Interest", JOptionPane.INFORMATION_MESSAGE ); - - System.exit( 0 ); // terminate the application - } - } diff --git a/java/_Basics/Calculator In Java.java b/java/_Basics/Calculator In Java.java deleted file mode 100644 index a305e86..0000000 --- a/java/_Basics/Calculator In Java.java +++ /dev/null @@ -1,157 +0,0 @@ -Calculator In Java - -import java.awt.*; -import java.awt.event.*; -import java.applet.*; - -public class CalculatorApplet extends Applet implements ActionListener -{ -private Button keysArray[]; -private Panel keyPad; -private TextField lcdField; -private double result; -private boolean first; -private boolean foundKey; -static boolean clearText; -private int prevOperator; - -public void init() -{ - lcdField = new TextField(20); - keyPad = new Panel (); - keysArray = new Button[17]; - result = 0.0; - prevOperator = 0; - first = true; - clearText = true; - - //Set frame layout manager setLayout(new BorderLayout()); - - lcdField.setEditable(false); - - //Create buttons - for (int i = 0; i <=9; i++) - keysArray[i] = new Button(String.valueOf(i)); - keysArray[10] = new Button("/"); - keysArray[11] = new Button("*"); - keysArray[12] = new Button("-"); - keysArray[13] = new Button("+"); - keysArray[14] = new Button("="); - keysArray[15] = new Button("."); - keysArray[16] = new Button("CLR"); - - //Set panel layout manager - keyPad.setLayout(new GridLayout (4,4)); - - //Add button to keyPad panel - for (int i = 7; i <=10; i++) //adds Button 7,8,9, and divide to -Panel - keyPad.add(keysArray[i]); - - for (int i = 4; i <6; i++) //adds buttons 4,5,6 to Panel - keyPad.add(keysArray[i]); - - keyPad.add(keysArray[11]); //adds multiply button to Panel - - for (int i = 1; i <= 3;i++) //adds buttons 1,2 and 3 to Panel - keyPad.add(keysArray[i]); - - keyPad.add(keysArray[12]);//adds minus button to Panel - - keyPad.add(keysArray[0]); //adds 0 key to Panel - - for (int i = 15; i >=13; i--) - keyPad.add(keysArray[i]); //adds decimal point, equal, and addition -ke -ys Panel - - add(lcdField, BorderLayout.NORTH); //adds text field to top of -Frame - add(keyPad, BorderLayout.CENTER); //adds Panel to center of Frame - add(keysArray[16], BorderLayout.EAST); //adds Clear key to right -side -of applet - - for(int i = 0; i < keysArray.length; i++) - keysArray[i].addActionListener(this); - } - - public void actionPerformed(ActionEvent e) - { - foundKey = false; - - //Search for the key pressed - for (int i = 0; i < keysArray.length && !foundKey; i++) - if(e.getSource() == keysArray[i]) //key match found - { - foundKey = true; - switch(i) - { - case 0: case 1: case 2: case 3: case 4: //number buttons - case 5: case 6: case 7: case 8: case 9: //0-9 - case 15: - if (clearText) - { - lcdField.setText(""); - clearText = false; - } - lcdField.setText(lcdField.getText() + - keysArray[i].getLabel()); - break; - - case 10:// divide button - case 11:// multiply button - case 12:// minus button - case 13:// plus button - case 14:// equal button - clearText = true; - if (first) // First operand - { - if(lcdField.getText().length()==0) - result = 0.0; - else - result = Double.valueOf(lcdField.getText()).doubleValue(); - - first = false; - prevOperator = i; //save previous operator - } - else //second operand already enter, so calculator total - { - switch(prevOperator) - { - case 10: //divide Button - result /= Double.valueOf(lcdField.getText()). - doubleValue(); - break; - case 11: //multiply Button - result *= Double.valueOf(lcdField.getText()). - doubleValue(); - break; - case 12: //minus button - result -= Double.valueOf(lcdField.getText()). - doubleValue(); - break; - case 13: //plus button - result += Double.valueOf(lcdField.getText()). - doubleValue(); - break; - } - lcdField.setText(Double.toString(result)); - if (i==14)//equal button - first = true; - else - prevOperator = i; //save previous opetator - } - break; - - case 16://Clear button - clearText = true; - first = true; - lcdField.setText(""); - result = 0.0; - prevOperator = 0; - break; - } - } - } - } diff --git a/java/_Basics/Calculator with both Standard and Scientific Mode.java b/java/_Basics/Calculator with both Standard and Scientific Mode.java deleted file mode 100644 index cf70fa6..0000000 --- a/java/_Basics/Calculator with both Standard and Scientific Mode.java +++ /dev/null @@ -1,634 +0,0 @@ -Calculator with both Standard and Scientific Mode - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; - -public class calculator extends JFrame implements ActionListener -{ - JTextField jtx; - double temp,temp1,result,a; - static double m1,m2; - int k=1,x=0,y=0,z=0; - char ch; - JButton -one,two,three,four,five,six,seven,eight,nine,zero,clr,pow2,pow3,exp; - JButton -plus,min,div,lg,rec,mul,eq,plmi,poin,mr,mc,mp,mm,sqrt,sin,cos,tan; - JMenuBar bar; - JMenu view; - JMenuItem exit; - JRadioButtonMenuItem standard,scientific; - JSeparator jp; - ButtonGroup bg; - Container cont; - JPanel textPanel,syntpanel,buttonpanel; - calculator() - { - cont=getContentPane(); - cont.setLayout(new BorderLayout()); - JPanel textpanel=new JPanel(); - Font font=new Font("Arial",Font.PLAIN,18); - jtx=new JTextField(25); - jtx.setFont(font); - jtx.setHorizontalAlignment(SwingConstants.RIGHT); - jtx.addKeyListener(new KeyAdapter() - { - public void keyTyped(KeyEvent keyevent) - { - char c=keyevent.getKeyChar(); - if(c>='0' && c<='9') - { - } - else - { - keyevent.consume(); - } - } - }); - textpanel.add(jtx); - buttonpanel=new JPanel(); - buttonpanel.setLayout(new GridLayout(5,4,2,2)); - boolean t=true; - syntpanel=new JPanel(); - syntpanel.setLayout(new GridLayout(5,1)); - bar=new JMenuBar(); - view=new JMenu("View"); - - standard =new JRadioButtonMenuItem("Standard",true); - standard.setMnemonic('S'); - standard.addItemListener(new radiohandler()); - scientific =new JRadioButtonMenuItem("Sceintific"); - standard.setMnemonic('c'); - scientific.addItemListener(new radiohandler()); - jp=new JSeparator(); - exit=new JMenuItem("Exit"); - standard.setMnemonic('E'); - exit.addActionListener(this); - bg=new ButtonGroup(); - bg.add(standard); - bg.add(scientific); - view.add(standard); - view.add(scientific); - view.add(jp); - view.add(exit); - bar.add(view); - setJMenuBar(bar); - - mr=new JButton("MR"); - buttonpanel.add(mr); - mr.addActionListener(this); - seven=new JButton("7"); - buttonpanel.add(seven); - seven.addActionListener(this); - eight=new JButton("8"); - buttonpanel.add(eight); - eight.addActionListener(this); - nine=new JButton("9"); - buttonpanel.add(nine); - nine.addActionListener(this); - clr=new JButton("AC"); - buttonpanel.add(clr); - clr.addActionListener(this); - - mc=new JButton("MC"); - buttonpanel.add(mc); - mc.addActionListener(this); - four=new JButton("4"); - buttonpanel.add(four); - four.addActionListener(this); - five=new JButton("5"); - buttonpanel.add(five); - five.addActionListener(this); - six=new JButton("6"); - buttonpanel.add(six); - six.addActionListener(this); - mul=new JButton("*"); - buttonpanel.add(mul); - mul.addActionListener(this); - - mp=new JButton("M+"); - buttonpanel.add(mp); - mp.addActionListener(this); - one=new JButton("1"); - buttonpanel.add(one); - one.addActionListener(this); - two=new JButton("2"); - buttonpanel.add(two); - two.addActionListener(this); - three=new JButton("3"); - buttonpanel.add(three); - three.addActionListener(this); - min=new JButton("-"); - buttonpanel.add(min); - min.addActionListener(this); - - mm=new JButton("M-"); - buttonpanel.add(mm); - mm.addActionListener(this); - zero=new JButton("0"); - buttonpanel.add(zero); - zero.addActionListener(this); - plmi=new JButton("+/-"); - buttonpanel.add(plmi); - plmi.addActionListener(this); - poin=new JButton("."); - buttonpanel.add(poin); - poin.addActionListener(this); - plus=new JButton("+"); - buttonpanel.add(plus); - plus.addActionListener(this); - - - rec=new JButton("1/x"); - buttonpanel.add(rec); - rec.addActionListener(this); - sqrt=new JButton("Sqrt"); - buttonpanel.add(sqrt); - sqrt.addActionListener(this); - lg=new JButton("log"); - buttonpanel.add(lg); - lg.addActionListener(this); - div=new JButton("/"); - div.addActionListener(this); - buttonpanel.add(div); - eq=new JButton("="); - buttonpanel.add(eq); - eq.addActionListener(this); - - sin=new JButton("SIN"); - syntpanel.add(sin); - sin.addActionListener(this); - cos=new JButton("COS"); - syntpanel.add(cos); - cos.addActionListener(this); - tan=new JButton("TAN"); - syntpanel.add(tan); - tan.addActionListener(this); - pow2=new JButton("x^2"); - syntpanel.add(pow2); - pow2.addActionListener(this); - pow3=new JButton("x^3"); - syntpanel.add(pow3); - pow3.addActionListener(this); - exp=new JButton("Exp"); - exp.addActionListener(this); - - cont.add("Center",buttonpanel); - cont.add("North",textpanel); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - } -class radiohandler implements ItemListener -{ -public void itemStateChanged(ItemEvent ie) - { - AbstractButton button=(AbstractButton)ie.getItem(); - String label=button.getText(); - { - if(label.equals("Standard")) - { - cont.remove(syntpanel); - validate(); - } - if(label.equals("Sceintific")) - { - cont.add("West",syntpanel); - validate(); - } - } - } -} -public void actionPerformed(ActionEvent e) -{ - String s=e.getActionCommand(); - if(s.equals("Exit")) - { - System.exit(0); - } - if(s.equals("1")) - { - if(z==0) - { - jtx.setText(jtx.getText()+"1"); - } - else - { - jtx.setText(""); - jtx.setText(jtx.getText()+"1"); - z=0; - } - } - if(s.equals("2")) - { - if(z==0) - { - jtx.setText(jtx.getText()+"2"); - } - else - { - jtx.setText(""); - jtx.setText(jtx.getText()+"2"); - z=0; - } - } - if(s.equals("3")) - { - if(z==0) - { - jtx.setText(jtx.getText()+"3"); - } - else - { - jtx.setText(""); - jtx.setText(jtx.getText()+"3"); - z=0; - } - } - if(s.equals("4")) - { - if(z==0) - { - jtx.setText(jtx.getText()+"4"); - } - else - { - jtx.setText(""); - jtx.setText(jtx.getText()+"4"); - z=0; - } - } - if(s.equals("5")) - { - if(z==0) - { - jtx.setText(jtx.getText()+"5"); - } - else - { - jtx.setText(""); - jtx.setText(jtx.getText()+"5"); - z=0; - } - } - if(s.equals("6")) - { - if(z==0) - { - jtx.setText(jtx.getText()+"6"); - } - else - { - jtx.setText(""); - jtx.setText(jtx.getText()+"6"); - z=0; - } - } - if(s.equals("7")) - { - if(z==0) - { - jtx.setText(jtx.getText()+"7"); - } - else - { - jtx.setText(""); - jtx.setText(jtx.getText()+"7"); - z=0; - } - } - if(s.equals("8")) - { - if(z==0) - { - jtx.setText(jtx.getText()+"8"); - } - else - { - jtx.setText(""); - jtx.setText(jtx.getText()+"8"); - z=0; - } - } - if(s.equals("9")) - { - if(z==0) - { - jtx.setText(jtx.getText()+"9"); - } - else - { - jtx.setText(""); - jtx.setText(jtx.getText()+"9"); - z=0; - } - } - if(s.equals("0")) - { - if(z==0) - { - jtx.setText(jtx.getText()+"0"); - } - else - { - jtx.setText(""); - jtx.setText(jtx.getText()+"0"); - z=0; - } - } - if(s.equals("AC")) - { - jtx.setText(""); - x=0; - y=0; - z=0; - } - if(s.equals("log")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - } - else - { - a=Math.log(Double.parseDouble(jtx.getText())); - jtx.setText(""); - jtx.setText(jtx.getText() + a); - } - } - if(s.equals("1/x")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - } - else - { - a=1/Double.parseDouble(jtx.getText()); - jtx.setText(""); - jtx.setText(jtx.getText() + a); - } - } - if(s.equals("Exp")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - } - else - { - a=Math.exp(Double.parseDouble(jtx.getText())); - jtx.setText(""); - jtx.setText(jtx.getText() + a); - } - } - if(s.equals("x^2")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - } - else - { - a=Math.pow(Double.parseDouble(jtx.getText()),2); - jtx.setText(""); - jtx.setText(jtx.getText() + a); - } - } - if(s.equals("x^3")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - } - else - { - a=Math.pow(Double.parseDouble(jtx.getText()),3); - jtx.setText(""); - jtx.setText(jtx.getText() + a); - } - } - if(s.equals("+/-")) - { - if(x==0) - { - jtx.setText("-"+jtx.getText()); - x=1; - } - else - { - jtx.setText(jtx.getText()); - } - } - if(s.equals(".")) - { - if(y==0) - { - jtx.setText(jtx.getText()+"."); - y=1; - } - else - { - jtx.setText(jtx.getText()); - } - } - if(s.equals("+")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - temp=0; - ch='+'; - } - else - { - temp=Double.parseDouble(jtx.getText()); - jtx.setText(""); - ch='+'; - y=0; - x=0; - } - jtx.requestFocus(); - } - if(s.equals("-")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - temp=0; - ch='-'; - } - else - { - x=0; - y=0; - temp=Double.parseDouble(jtx.getText()); - jtx.setText(""); - ch='-'; - } - jtx.requestFocus(); - } - if(s.equals("/")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - temp=1; - ch='/'; - } - else - { - x=0; - y=0; - temp=Double.parseDouble(jtx.getText()); - ch='/'; - jtx.setText(""); - } - jtx.requestFocus(); - } - if(s.equals("*")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - temp=1; - ch='*'; - } - else - { - x=0; - y=0; - temp=Double.parseDouble(jtx.getText()); - ch='*'; - jtx.setText(""); - } - jtx.requestFocus(); - } - if(s.equals("MC")) - { - m1=0; - jtx.setText(""); - } - if(s.equals("MR")) - { - jtx.setText(""); - jtx.setText(jtx.getText() + m1); - } - if(s.equals("M+")) - { - if(k==1) - { - m1=Double.parseDouble(jtx.getText()); - k++; - } - else - { - m1+=Double.parseDouble(jtx.getText()); - jtx.setText(""+m1); - } - } - if(s.equals("M-")) - { - if(k==1) - { - m1=Double.parseDouble(jtx.getText()); - k++; - } - else - { - m1-=Double.parseDouble(jtx.getText()); - jtx.setText(""+m1); - } - } - if(s.equals("Sqrt")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - } - else - { - a=Math.sqrt(Double.parseDouble(jtx.getText())); - jtx.setText(""); - jtx.setText(jtx.getText() + a); - } - } - if(s.equals("SIN")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - } - else - { - a=Math.sin(Double.parseDouble(jtx.getText())); - jtx.setText(""); - jtx.setText(jtx.getText() + a); - } - } - if(s.equals("COS")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - } - else - { - a=Math.cos(Double.parseDouble(jtx.getText())); - jtx.setText(""); - jtx.setText(jtx.getText() + a); - } - } - if(s.equals("TAN")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - } - else - { - a=Math.tan(Double.parseDouble(jtx.getText())); - jtx.setText(""); - jtx.setText(jtx.getText() + a); - } - } - if(s.equals("=")) - { - if(jtx.getText().equals("")) - { - jtx.setText(""); - } - else - { - temp1 = Double.parseDouble(jtx.getText()); - switch(ch) - { - case '+': - result=temp+temp1; - break; - case '-': - result=temp-temp1; - break; - case '/': - result=temp/temp1; - break; - case '*': - result=temp*temp1; - break; - } - jtx.setText(""); - jtx.setText(jtx.getText() + result); - z=1; - } - } - jtx.requestFocus(); - } -public static void main(String args[]) - { - calculator n=new calculator(); - n.setTitle("CALCULATOR"); - n.setSize(370,250); - n.setResizable(false); - n.setVisible(true); - } -} diff --git a/java/_Basics/Calling Windows Runtime Commands.java b/java/_Basics/Calling Windows Runtime Commands.java deleted file mode 100644 index 8426706..0000000 --- a/java/_Basics/Calling Windows Runtime Commands.java +++ /dev/null @@ -1,12 +0,0 @@ -Calling Windows Runtime Commands - -import java.io.*; -public class Win -{ -public static void main(String[] Miller) throws IOException -{ - Process process = -Runtime.getRuntime().exec("/C:WINNTsystem32calculator.exe"); - process.waitFor(); -} -} diff --git a/java/_Basics/Catching an exception.java b/java/_Basics/Catching an exception.java deleted file mode 100644 index ff4e006..0000000 --- a/java/_Basics/Catching an exception.java +++ /dev/null @@ -1,15 +0,0 @@ -Catching an exception - - - -public class CatchingAnException { - public static void main( String[] args ) { - try { - // this throws a runtime exception, that is a divide by zero - int a = 3 / 0; - } - catch( ArithmeticException aex ) { - aex.printStackTrace(); - } - } -} diff --git a/java/_Basics/Check The Equality Of Two Arrays In Java.java b/java/_Basics/Check The Equality Of Two Arrays In Java.java deleted file mode 100644 index c9f87d3..0000000 --- a/java/_Basics/Check The Equality Of Two Arrays In Java.java +++ /dev/null @@ -1,27 +0,0 @@ - public class EqualityOfTwoArrays { - public static void main(String[] args) { - int[] arrayOne = { - 2, 5, 1, 7, 4 - } - ; - int[] arrayTwo = { - 2, 5, 1, 7, 4 - } - ; - boolean equalOrNot = true; - if(arrayOne.length == arrayTwo.length) { - for (int i = 0; i < arrayOne.length; i++) { - if(arrayOne[i] != arrayTwo[i]) { - equalOrNot = false; - } - } - } else { - equalOrNot = false; - } - if (equalOrNot) { - System.out.println("Two Arrays Are Equal"); - } else { - System.out.println("Two Arrays Are Not equal"); - } - } - } \ No newline at end of file diff --git a/java/_Basics/Complex.java b/java/_Basics/Complex.java deleted file mode 100644 index 48b1a83..0000000 --- a/java/_Basics/Complex.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.jwetherell.algorithms.numbers; - -/** - * A complex number is a number that can be expressed in the form a + bi, where a and b are real numbers and i is the - * imaginary unit, satisfying the equation i2 = −1.[1] In this expression, a is the real part and b is the imaginary - * part of the complex number. If z=a+bi z=a+bi, then Rz=a, Iz=b. - *

- * http://en.wikipedia.org/wiki/Complex_number - *
- * @author Mateusz Cianciara - * @author Justin Wetherell - */ -public class Complex { - - public double real; - public double imaginary; - - public Complex() { - this.real = 0.0; - this.imaginary = 0.0; - } - - public Complex(double r, double i) { - this.real = r; - this.imaginary = i; - } - - public Complex multiply(final Complex x) { - final Complex copy = new Complex(this.real, this.imaginary); - copy.real = this.real * x.real - this.imaginary * x.imaginary; - copy.imaginary = this.imaginary * x.real + this.real * x.imaginary; - return copy; - } - - public Complex add(final Complex x) { - final Complex copy = new Complex(this.real, this.imaginary); - copy.real += x.real; - copy.imaginary += x.imaginary; - return copy; - } - - public Complex sub(final Complex x) { - final Complex copy = new Complex(this.real, this.imaginary); - copy.real -= x.real; - copy.imaginary -= x.imaginary; - return copy; - } - - public double abs() { - return Math.sqrt(this.real * this.real + this.imaginary * this.imaginary); - } - - public String toString() { - return "(" + this.real + "," + this.imaginary + ")"; - } - - public static Complex polar(final double rho, final double theta) { - return (new Complex(rho * Math.cos(theta), rho * Math.sin(theta))); - } -} diff --git a/java/_Basics/Constants.java b/java/_Basics/Constants.java deleted file mode 100644 index 6dc7ad3..0000000 --- a/java/_Basics/Constants.java +++ /dev/null @@ -1,24 +0,0 @@ -Constants - - - -public class Constants { - // define two class-level constants with static final - private static final int MAX_VALUE = 100; - private static final String LOCAL_URL = "http://localhost:8080/"; - - public static void main( String[] args ) { - // define MY_PIE as a local constant - final double MY_PIE = 3.14; - - System.out.println( Constants.MAX_VALUE ); - System.out.println( Constants.LOCAL_URL ); - System.out.println( MY_PIE ); - - // MY_PIE = 3.15 result in an error, because MY_PIE is a constant - } - - public static void execute( final int min, final int max ) { - // min and max cannot be altered within this method - } -} diff --git a/java/_Basics/Constructors.java b/java/_Basics/Constructors.java deleted file mode 100644 index 7e0093e..0000000 --- a/java/_Basics/Constructors.java +++ /dev/null @@ -1,36 +0,0 @@ -Constructors - - - -public class Constructors { - private static final String DEFAULT_MSG = "hey"; - private static final int DEFAULT_AMOUNT = 25; - - private String msg; - private int amount; - - public Constructors( String msg, int amount ) { - // use the 'this' keyword to reference to this object instance - // variables, with out, msg and amount refer to the formal parameters - this.msg = msg; - this.amount = amount; - } - - public Constructors( String msg ) { - // must be first line in a constructor and calls the constructor - // within this class with those formal parameters - this( msg, DEFAULT_AMOUNT ); - } - - public Constructors() { - // must be first line in a constructor and calls the constructor - // within this class with those formal parameters - this( DEFAULT_MSG ); - } - - public static void main( String[] args ) { - // here, we demonstrate how all three constructors - // can be called to construct an object - new Constructors(); - } -} diff --git a/java/_Basics/Continue Statements.java b/java/_Basics/Continue Statements.java deleted file mode 100644 index eb80d97..0000000 --- a/java/_Basics/Continue Statements.java +++ /dev/null @@ -1,17 +0,0 @@ -Continue Statements - - - -public class ContinueStatements { - public static void main( String[] args ) { - // when i is 5, got back to loop, test and increment - // in this chase the value 5 is not output - for( int i = 0; i < 10; i++ ) { - if( i == 5 ) { - continue; - } - System.out.println( i ); - } - - } -} diff --git a/java/_Basics/Coprimes.java b/java/_Basics/Coprimes.java deleted file mode 100644 index 0877ce4..0000000 --- a/java/_Basics/Coprimes.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.jwetherell.algorithms.mathematics; - -/** - * In number theory, two integers a and b are said to be relatively prime, mutually prime, or coprime (also spelled - * co-prime)[1] if the only positive integer that divides both of them is 1. That is, the only common positive factor - * of the two numbers is 1. This is equivalent to their greatest common divisor being 1. - *

- * http://en.wikipedia.org/wiki/Coprime_integers - *
- * @author Szymon Stankiewicz - * @author Justin Wetherell - */ -public class Coprimes { - - private Coprimes() { } - - /** - * - * Euler's totient function. Because this function is multiplicative such implementation is possible. - *

- * Time complexity: O(sqrt(n)) - *

- * @param n Long integer - * @return number of coprimes smaller or equal to n - */ - public static long getNumberOfCoprimes(long n) { - if(n < 1) - return 0; - long res = 1; - for(int i = 2; i*i <= n; i++) { - int times = 0; - while(n%i == 0) { - res *= (times > 0 ? i : i-1); - n /= i; - times++; - } - } - if(n > 1) - res *= n-1; - return res; - } -} diff --git a/java/_Basics/Demonstrating the runnable interface.java b/java/_Basics/Demonstrating the runnable interface.java deleted file mode 100644 index 5376adf..0000000 --- a/java/_Basics/Demonstrating the runnable interface.java +++ /dev/null @@ -1,118 +0,0 @@ -Demonstrating the runnable interface - - import java.awt.*; - import java.awt.event.*; - import javax.swing.*; - - public class RandomCharacters extends JApplet implements Runnable, ActionListener - { - private String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - private JLabel outputs[]; - private JCheckBox checkboxes[]; - private final static int SIZE = 3; - - private Thread threads[]; - private boolean suspended[]; - - public void init() - { - outputs = new JLabel[ SIZE ]; - checkboxes = new JCheckBox[ SIZE ]; - threads = new Thread[ SIZE ]; - suspended = new boolean[ SIZE ]; - - Container c = getContentPane(); - c.setLayout( new GridLayout( SIZE, 2, 5, 5 ) ); - - for ( int i = 0; i < SIZE; i++ ) - { - outputs[ i ] = new JLabel(); - outputs[ i ].setBackground( Color.green ); - outputs[ i ].setOpaque( true ); - c.add( outputs[ i ] ); - - checkboxes[ i ] = new JCheckBox( "Suspended" ); - checkboxes[ i ].addActionListener( this ); - c.add( checkboxes[ i ] ); - } - } - - public void start() - { - // create threads and start every time start is called - for ( int i = 0; i < threads.length; i++ ) - { - threads[ i ] = new Thread( this, "Thread " + (i + 1) ); - threads[ i ].start(); - } - } - - public void run() - { - Thread currentThread = Thread.currentThread(); - int index = getIndex( currentThread ); - char displayChar; - - while ( threads[ index ] == currentThread ) - { - // sleep from 0 to 1 second - try - { - Thread.sleep( (int) ( Math.random() * 1000 ) ); - - synchronized( this ) - { - while ( suspended[ index ] && threads[ index ] == currentThread ) - wait(); - } - } - catch ( InterruptedException e ) - { - System.err.println( "sleep interrupted" ); - } - - displayChar = alphabet.charAt( (int) ( Math.random() * 26 ) ); - outputs[ index ].setText( currentThread.getName() + - ": " + displayChar ); - } - - System.err.println( currentThread.getName() + " terminating" ); - } - - private int getIndex( Thread current ) - { - for ( int i = 0; i < threads.length; i++ ) - if ( current == threads[ i ] ) - return i; - - return -1; - } - - public synchronized void stop() - { - // stop threads every time stop is called - // as the user browses another Web page - for ( int i = 0; i < threads.length; i++ ) - threads[ i ] = null; - - notifyAll(); - } - - public synchronized void actionPerformed( ActionEvent e ) - { - for ( int i = 0; i < checkboxes.length; i++ ) - { - if ( e.getSource() == checkboxes[ i ] ) - { - suspended[ i ] = !suspended[ i ]; - - outputs[ i ].setBackground( !suspended[ i ] ? Color.green : Color.red ); - - if ( !suspended[ i ] ) - notify(); - - return; - } - } - } - } diff --git a/java/_Basics/Deposit Account.java b/java/_Basics/Deposit Account.java deleted file mode 100644 index 754eff3..0000000 --- a/java/_Basics/Deposit Account.java +++ /dev/null @@ -1,32 +0,0 @@ -Deposit Account - -package com.ack.learning.examples.account; - -public class DepositAccount { - private double amount; - private String name; - - public DepositAccount() { - } - - public DepositAccount( String theName, double theAmount ) { - name = theName; - amount = theAmount; - } - - public double getAmount() { - return amount; - } - - public String getName() { - return name; - } - - public static void main( String[] args ) { - DepositAccount hsbc = new DepositAccount( "barry", 345.45 ); - DepositAccount halifax = new DepositAccount( "hector", 45.76 ); - - System.out.println( hsbc.getName() ); - System.out.println( halifax.getName() ); - } -} diff --git a/java/_Basics/Distance.java b/java/_Basics/Distance.java deleted file mode 100644 index ef8e47e..0000000 --- a/java/_Basics/Distance.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.jwetherell.algorithms.mathematics; - -public class Distance { - - private Distance() { } - - /* - * Chess distance - */ - public static final long chebyshevDistance(long[] point1, long[] point2) { - long x1 = point1[0]; - long y1 = point1[1]; - long x2 = point2[0]; - long y2 = point2[1]; - return Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)); - } - - public static final double squaredDistance(double x1, double y1, double x2, double y2) { - double x = x1 - x2; - double y = y1 - y2; - double sqr = (x * x) + (y * y); - return sqr; - } - - public static final double euclideanDistance(double x1, double y1, double x2, double y2) { - double x = Math.pow((x1 - x2), 2); - double y = Math.pow((y1 - y2), 2); - double sqrt = Math.sqrt(x + y); - return sqrt; - } -} diff --git a/java/_Basics/Division.java b/java/_Basics/Division.java deleted file mode 100644 index c133f74..0000000 --- a/java/_Basics/Division.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.jwetherell.algorithms.mathematics; - -public class Division { - - public static final long division(int a, int b) { - long result = ((long) a) / ((long) b); - return result; - } - - public static final long divisionUsingLoop(int a, int b) { - int absA = Math.abs(a); - int absB = Math.abs(b); - - long temp = absA; - long result = 0; - while (temp >= 0) { - temp -= absB; - if (temp >= 0) - result++; - } - return (a > 0 && b > 0 || a < 0 && b < 0) ? result : -result; - } - - public static final long divisionUsingRecursion(int a, int b) { - int absA = Math.abs(a); - int absB = Math.abs(b); - - long result = 1; - int diff = absA - absB; - if (diff > 0 && diff <= 1) { - return result; - } else if (diff < 0) { - return 0; - } - - result += divisionUsingRecursion(diff, absB); - return (a > 0 && b > 0 || a < 0 && b < 0) ? result : -result; - } - - public static final long divisionUsingMultiplication(int a, int b) { - int absA = Math.abs(a); - int absB = Math.abs(b); - - int temp = absB; - int counter = 0; - while (temp <= absA) { - temp = temp << 1; - counter++; - } - absA -= absB << (counter - 1); - long result = (long) Math.pow(2, counter - 1); - if (absB <= absA) - result += divisionUsingMultiplication(absA, absB); - return (a > 0 && b > 0 || a < 0 && b < 0) ? result : -result; - } - - public static final long divisionUsingShift(int a, int b) { - int absA = Math.abs(a); - int absB = Math.abs(b); - int tempA, tempB, counter; - - long result = 0L; - while (absA >= absB) { - tempA = absA >> 1; // Right shift "a" - tempB = absB; - counter = 1; - while (tempA >= tempB) { // Double "tempB" until it's larger than - // "tempA" - tempB <<= 1; - counter <<= 1; // Double the counter - } - absA -= tempB; // Subtract "tempB" from "a" - result += counter; // Add counter (2^number of left shifts) - } - return (a > 0 && b > 0 || a < 0 && b < 0) ? result : -result; - } - - public static final long divisionUsingLogs(int a, int b) { - long absA = Math.abs(a); - long absB = Math.abs(b); - double logBase10A = Math.log10(absA); - double logBase10B = Math.log10(absB); - double powOf10 = Math.pow(10, (logBase10A - logBase10B)); - long result = (long) Math.floor(powOf10); - return (a > 0 && b > 0 || a < 0 && b < 0) ? result : -result; - } -} diff --git a/java/_Basics/Factorial (Java).java b/java/_Basics/Factorial (Java).java deleted file mode 100644 index db8abc1..0000000 --- a/java/_Basics/Factorial (Java).java +++ /dev/null @@ -1,13 +0,0 @@ -class FactorialExample -{ - public static void main(String args[]) - { - int i,fact=1; - int number=5;//It is the number to calculate factorial - for(i=1; i<=number; i++) - { - fact=fact*i; - } - System.out.println("Factorial of "+number+" is: "+fact); - } -} \ No newline at end of file diff --git a/java/_Basics/FastFourierTransform.java b/java/_Basics/FastFourierTransform.java deleted file mode 100644 index 93dc412..0000000 --- a/java/_Basics/FastFourierTransform.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.jwetherell.algorithms.mathematics; - -import com.jwetherell.algorithms.numbers.Complex; - -/** - * A fast Fourier transform (FFT) algorithm computes the discrete Fourier transform (DFT) of a sequence, or its inverse. - * Fourier analysis converts a signal from its original domain (often time or space) to a representation in the frequency - * domain and vice versa. An FFT rapidly computes such transformations by factorizing the DFT matrix into a product of - * sparse (mostly zero) factors. - *

- * http://en.wikipedia.org/wiki/Fast_Fourier_transform - *
- * @author Mateusz Cianciara - * @author Justin Wetherell - */ -public class FastFourierTransform { - - private FastFourierTransform() { } - - /** - * The Cooley–Tukey algorithm, named after J.W. Cooley and John Tukey, is the most common fast Fourier transform - * (FFT) algorithm. It re-expresses the discrete Fourier transform (DFT) of an arbitrary composite size N = N1N2 - * in terms of N1 smaller DFTs of sizes N2, recursively, to reduce the computation time to O(N log N) for highly - * composite N (smooth numbers). - *

- * http://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm - *
- * @param coefficients size must be power of 2 - */ - public static void cooleyTukeyFFT(Complex[] coefficients) { - final int size = coefficients.length; - if (size <= 1) - return; - - final Complex[] even = new Complex[size / 2]; - final Complex[] odd = new Complex[size / 2]; - for (int i = 0; i < size; i++) { - if (i % 2 == 0) { - even[i / 2] = coefficients[i]; - } else { - odd[(i - 1) / 2] = coefficients[i]; - } - } - cooleyTukeyFFT(even); - cooleyTukeyFFT(odd); - for (int k = 0; k < size / 2; k++) { - Complex t = Complex.polar(1.0, -2 * Math.PI * k / size).multiply(odd[k]); - coefficients[k] = even[k].add(t); - coefficients[k + size / 2] = even[k].sub(t); - } - } -} diff --git a/java/_Basics/Fibonacci (Java).java b/java/_Basics/Fibonacci (Java).java deleted file mode 100644 index d58dbec..0000000 --- a/java/_Basics/Fibonacci (Java).java +++ /dev/null @@ -1,15 +0,0 @@ -class Fibonacci -{ - public static void main(String args[]) - { - int n1=0,n2=1,n3,i,count=10; - System.out.print(n1+" "+n2);//printing 0 and 1 - for(i=2; i - * - * https://en.wikipedia.org/wiki/Fibonacci_number - *
- * @author Justin Wetherell - */ -public class FibonacciSequence { - - private static final double INVERSE_SQUARE_ROOT_OF_5 = 1 / Math.sqrt(5); // Inverse of the square root of 5 - private static final double PHI = (1 + Math.sqrt(5)) / 2; // Golden ratio - - private FibonacciSequence() {} - - public static final long fibonacciSequenceUsingLoop(int n) { - final long[] array = new long[n + 1]; - int counter = 0; - while (counter <= n) { - long r = 0; - if (counter > 1) { - r = array[counter - 1] + array[counter - 2]; - } else if (counter == 1) { - r = 1; - } - // If r goes below zero then we have run out of bits in the long - if (r < 0) - throw new IllegalArgumentException("Run out of bits in long, n="+n); - array[counter] = r; - counter++; - } - - return array[n]; - } - - /** - * Recursion with memoization - */ - public static final long fibonacciSequenceUsingRecursion(int n) { - // Using the array to store values already computed - final long[] array = new long[n + 1]; - return fibonacciSequenceUsingRecursion(array,n); - } - - private static final long fibonacciSequenceUsingRecursion(long[] array, int n) { - if (n == 0 || n == 1) - return n; - - // If array already has a value then it has previously been computed - if (array[n] != 0) - return array[n]; - - final String exception = "Run out of bits in long, n="+n; - - final long r1 = fibonacciSequenceUsingRecursion(array, (n - 1)); - array[n-1] = r1; // memoization - // If r1 goes below zero then we have run out of bits in the long - if (r1 < 0) - throw new IllegalArgumentException(exception); - - final long r2 = fibonacciSequenceUsingRecursion(array, (n - 2)); - array[n-2] = r2; // memoization - // If r2 goes below zero then we have run out of bits in the long - if (r2 < 0) - throw new IllegalArgumentException(exception); - - final long r = r1 + r2; - // If r goes below zero then we have run out of bits in the long - if (r < 0) - throw new IllegalArgumentException("Run out of bits in long, n="+n); - - array[n] = r; // memoization - - return r; - } - - public static final long fibonacciSequenceUsingMatrixMultiplication(int n) { - // m = [ 1 , 1 ] - // [ 1 , 0 ] - final long[][] matrix = new long[2][2]; - matrix[0][0] = 1; - matrix[0][1] = 1; - matrix[1][0] = 1; - matrix[1][1] = 0; - - long[][] temp = new long[2][2]; - temp[0][0] = 1; - temp[0][1] = 1; - temp[1][0] = 1; - temp[1][1] = 0; - - int counter = n; - while (counter > 0) { - temp = multiplyMatrices(matrix, temp); - // Subtract an additional 1 the first time in the loop because the - // first multiplication is actually n -= 2 since it multiplying two matrices - counter -= (counter == n) ? 2 : 1; - } - final long r = temp[0][1]; - // If r goes below zero then we have run out of bits in the long - if (r < 0) - throw new IllegalArgumentException("Run out of bits in long, n="+n); - return r; - } - - private static final long[][] multiplyMatrices(long[][] A, long[][] B) { - final long a = A[0][0]; - final long b = A[0][1]; - final long c = A[1][0]; - final long d = A[1][1]; - - final long e = B[0][0]; - final long f = B[0][1]; - final long g = B[1][0]; - final long h = B[1][1]; - - B[0][0] = a * e + b * g; - B[0][1] = a * f + b * h; - B[1][0] = c * e + d * g; - B[1][1] = c * f + d * h; - - return B; - } - - public static final long fibonacciSequenceUsingBinetsFormula(int n) { - final long r = (long) Math.floor(Math.pow(PHI, n) * INVERSE_SQUARE_ROOT_OF_5 + 0.5); - // If r hits max value then we have run out of bits in the long - if (r == Long.MAX_VALUE) - throw new IllegalArgumentException("Run out of bits in long, n="+n); - return r; - } -} diff --git a/java/_Basics/For Loops.java b/java/_Basics/For Loops.java deleted file mode 100644 index 03d201d..0000000 --- a/java/_Basics/For Loops.java +++ /dev/null @@ -1,26 +0,0 @@ -For Loops - - - -public class ForLoops { - public static void main( String[] args ) { - // simple for loop - System.out.println( "loop #1" ); - for( int i = 0; i < 10; i++ ) { - System.out.println( i ); - } - - // loop with multiple iteration constants - System.out.println( "loop #2" ); - for( int i = 1,j = 2; i < 10 && j < 5; i += 2, j-- ) { - System.out.println( j ); - } - - // infinite loop - System.out.println( "infinite loop #3" ); - for( ; ; ) { - // but we are going to break out of it - break; - } - } -} diff --git a/java/_Basics/GetTheCurrentTime.java b/java/_Basics/GetTheCurrentTime.java deleted file mode 100644 index 8a12c2d..0000000 --- a/java/_Basics/GetTheCurrentTime.java +++ /dev/null @@ -1,20 +0,0 @@ -GetTheCurrentTime - -package com.ack.j2se.date; - -import java.util.Calendar; -import java.util.Date; - -public class GetTheCurrentTime { - public static void main( String[] args ) { - // one way - long currentTimeInMillis = System.currentTimeMillis(); - Date today = new Date( currentTimeInMillis ); - System.out.println( today ); - - // another way - Calendar cal = Calendar.getInstance(); - today = cal.getTime(); - System.out.println( today ); - } -} diff --git a/java/_Basics/GreatestCommonDivisor.java b/java/_Basics/GreatestCommonDivisor.java deleted file mode 100644 index f12889e..0000000 --- a/java/_Basics/GreatestCommonDivisor.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.jwetherell.algorithms.mathematics; - -/** - * In mathematics, the greatest common divisor (gcd) of two or more integers, when at least one of them is not - * zero, is the largest positive integer that is a divisor of both numbers. - *

- * http://en.wikipedia.org/wiki/Greatest_common_divisor - *
- * @author Szymon Stankiewicz - * @author Justin Wetherell - */ -public class GreatestCommonDivisor { - - /** - * Calculate greatest common divisor of two numbers using recursion. - *

- * Time complexity O(log(a+b)) - *
- * @param a Long integer - * @param b Long integer - * @return greatest common divisor of a and b - */ - public static long gcdUsingRecursion(long a, long b) { - a = Math.abs(a); - b = Math.abs(b); - return a == 0 ? b : gcdUsingRecursion(b%a, a); - } - - /** - * A much more efficient method is the Euclidean algorithm, which uses a division algorithm such as long division - * in combination with the observation that the gcd of two numbers also divides their difference. - *

- * http://en.wikipedia.org/wiki/Greatest_common_divisor#Using_Euclid.27s_algorithm - */ - public static final long gcdUsingEuclides(long x, long y) { - long greater = x; - long smaller = y; - if (y > x) { - greater = y; - smaller = x; - } - - long result = 0; - while (true) { - if (smaller == greater) { - result = smaller; // smaller == greater - break; - } - - greater -= smaller; - if (smaller > greater) { - long temp = smaller; - smaller = greater; - greater = temp; - } - } - return result; - } -} diff --git a/java/_Basics/Hanoi Algorithm Recursion.java b/java/_Basics/Hanoi Algorithm Recursion.java deleted file mode 100644 index 546cb4f..0000000 --- a/java/_Basics/Hanoi Algorithm Recursion.java +++ /dev/null @@ -1,23 +0,0 @@ -Hanoi Algorithm Recursion - - - - -public class HanoiAlgorithmRecursion { - public static void movetower( int height, int fromT, int toT, int usingT ) { - if( height > 0 ) { - movetower( height - 1, fromT, usingT, toT ); - moveDisk( fromT, toT ); - movetower( height - 1, usingT, toT, fromT ); - } - } - - public static void moveDisk( int takeoff, int puton ) { - System.out.println( takeoff + "->" + puton ); - } - - public static void main( String argv[] ) { - int numberOfDisks = 3; - movetower( numberOfDisks, 1, 3, 2 ); - } -} diff --git a/java/_Basics/Horoscope.java b/java/_Basics/Horoscope.java deleted file mode 100644 index a3a92bd..0000000 --- a/java/_Basics/Horoscope.java +++ /dev/null @@ -1,73 +0,0 @@ -Horoscope - -import javax.swing.*; -import java.awt.event.*; -import java.awt.*; - -public class Factorial extends JFrame - { - private JTextField txtNum; - private JLabel lblNum, lblRes; - private JButton btnCompute; - - public static int ComputeFactorial(int number) - { - int n = number-1; - do - { - number = number*n; - n--; - }while(n>=1); - return number; - } - - public Factorial() - { - super("GUI Factorial"); - Container c = getContentPane(); - c.setLayout(new FlowLayout()); - lblNum = new JLabel("Enter an integer: "); - txtNum = new JTextField(10); - lblRes = new JLabel(); - btnCompute = new JButton("Compute"); - - btnCompute.addActionListener - ( - new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - String str = txtNum.getText(); - int tmp = Integer.parseInt(str); - tmp = ComputeFactorial(tmp); - lblRes.setText("The factorial of "+str+" is "+tmp); - } - } - ); - - c.add(lblNum); - c.add(txtNum); - c.add(btnCompute); - c.add(lblRes); - setSize(200,150); - show(); - } - - public static void main(String args[]) - { - Factorial app = new Factorial(); - app.setResizable(false); - app.setLocation(400,200); - app.addWindowListener - ( - new WindowAdapter() - { - public void windowClosing(WindowEvent e) - { - System.exit(0); - } - } - ); - } - -} diff --git a/java/_Basics/How to add time(Days, years , seconds) to Date.java b/java/_Basics/How to add time(Days, years , seconds) to Date.java deleted file mode 100644 index 94f6f7f..0000000 --- a/java/_Basics/How to add time(Days, years , seconds) to Date.java +++ /dev/null @@ -1,15 +0,0 @@ - import java.util.*; - public class Main { - public static void main(String[] args) throws Exception { - Date d1 = new Date(); - Calendar cl = Calendar. getInstance(); - cl.setTime(d1); - System.out.println("today is " + d1.toString()); - cl. add(Calendar.MONTH, 1); - System.out.println("date after a month will be " + cl.getTime().toString() ); - cl. add(Calendar.HOUR, 70); - System.out.println("date after 7 hrs will be " + cl.getTime().toString() ); - cl. add(Calendar.YEAR, 3); - System.out.println("date after 3 years will be " + cl.getTime().toString() ); - } - } \ No newline at end of file diff --git a/java/_Basics/How to change(set) or Get the last modification time of a file in java .java b/java/_Basics/How to change(set) or Get the last modification time of a file in java .java deleted file mode 100644 index 98d9762..0000000 --- a/java/_Basics/How to change(set) or Get the last modification time of a file in java .java +++ /dev/null @@ -1,11 +0,0 @@ - import java.io.File; - import java.util.Date; - - public class Main { - public static void main(String[] args) { - File file = new File("Main.java"); - Long lastModified = file.lastModified(); - Date date = new Date(lastModified); - System.out.println(date); - } - } \ No newline at end of file diff --git a/java/_Basics/How to compare two strings.java b/java/_Basics/How to compare two strings.java deleted file mode 100644 index ced522c..0000000 --- a/java/_Basics/How to compare two strings.java +++ /dev/null @@ -1,10 +0,0 @@ - public class StringCompareEmp { - public static void main(String args[]) { - String str = "Hello World"; - String anotherString = "hello world"; - Object objStr = str; - System.out.println( str.compareTo(anotherString) ); - System.out.println( str.compareToIgnoreCase(anotherString) ); - System.out.println( str.compareTo(objStr.toString())); - } - } \ No newline at end of file diff --git a/java/_Basics/How to convert a string totally into upper case.java b/java/_Basics/How to convert a string totally into upper case.java deleted file mode 100644 index 2f83a6e..0000000 --- a/java/_Basics/How to convert a string totally into upper case.java +++ /dev/null @@ -1,8 +0,0 @@ - public class StringToUpperCaseEmp { - public static void main(String[] args) { - String str = "string abc touppercase "; - String strUpper = str.toUpperCase(); - System.out.println("Original String: " + str); - System.out.println("String changed to upper case: "+ strUpper); - } - } \ No newline at end of file diff --git a/java/_Basics/How to display date in different formats .java b/java/_Basics/How to display date in different formats .java deleted file mode 100644 index 47e815c..0000000 --- a/java/_Basics/How to display date in different formats .java +++ /dev/null @@ -1,16 +0,0 @@ - import java.text.*; - import java.util.*; - public class Main { - public static void main(String[] args) { - Date dt = new Date(1000000000000L); - DateFormat[] dtformat = new DateFormat[6]; - dtformat[0] = DateFormat.getInstance(); - dtformat[1] = DateFormat.getDateInstance(); - dtformat[2] = DateFormat.getDateInstance(DateFormat.MEDIUM); - dtformat[3] = DateFormat.getDateInstance(DateFormat.FULL); - dtformat[4] = DateFormat.getDateInstance(DateFormat.LONG); - dtformat[5] = DateFormat.getDateInstance(DateFormat.SHORT); - for (DateFormat dateform : dtformat) - System.out.println(dateform.format(dt)); - } - } \ No newline at end of file diff --git a/java/_Basics/How to display name of a month in (MMM) format.java b/java/_Basics/How to display name of a month in (MMM) format.java deleted file mode 100644 index c421859..0000000 --- a/java/_Basics/How to display name of a month in (MMM) format.java +++ /dev/null @@ -1,11 +0,0 @@ - import java.util.Calendar; - import java.util.Formatter; - public class MainClass { - public static void main(String args[]) { - Formatter fmt = new Formatter(); - Calendar cal = Calendar.getInstance(); - fmt = new Formatter(); - fmt.format("%tB %tb %tm", cal, cal, cal); - System.out.println(fmt); - } - } \ No newline at end of file diff --git a/java/_Basics/How to display name of the weekdays.java b/java/_Basics/How to display name of the weekdays.java deleted file mode 100644 index 2dfa4e3..0000000 --- a/java/_Basics/How to display name of the weekdays.java +++ /dev/null @@ -1,11 +0,0 @@ - import java.text.SimpleDateFormat; - import java.text.DateFormatSymbols; - public class Main { - public static void main(String[] args) { - String[] weekdays = new DateFormatSymbols().getWeekdays(); - for (int i = 2; i < (weekdays.length-1); i++) { - String weekday = weekdays[i]; - System.out.println("weekday = " + weekday); - } - } - } \ No newline at end of file diff --git a/java/_Basics/How to display time in different countrys format.java b/java/_Basics/How to display time in different countrys format.java deleted file mode 100644 index 48a7aad..0000000 --- a/java/_Basics/How to display time in different countrys format.java +++ /dev/null @@ -1,11 +0,0 @@ - import java.text.DateFormat; - import java.util.*; - public class Main { - public static void main(String[] args) throws Exception { - Date d1 = new Date(); - System.out.println("today is "+ d1.toString()); - Locale locItalian = new Locale("it","ch"); - DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, locItalian); - System.out.println("today is in Italian Language in Switzerland Format : "+ df.format(d1)); - } - } \ No newline at end of file diff --git a/java/_Basics/How to find which week of the year, month.java b/java/_Basics/How to find which week of the year, month.java deleted file mode 100644 index 1d484a1..0000000 --- a/java/_Basics/How to find which week of the year, month.java +++ /dev/null @@ -1,11 +0,0 @@ - import java.util.*; - public class Main { - public static void main(String[] args) throws Exception { - Date d1 = new Date(); - Calendar cl = Calendar. getInstance(); - cl.setTime(d1); - System.out.println("today is "+ cl.WEEK_OF_YEAR+ " week of the year"); - System.out.println("today is a "+cl.DAY_OF_MONTH + "month of the year"); - System.out.println("today is a "+cl.WEEK_OF_MONTH +"week of the month"); - } - } \ No newline at end of file diff --git a/java/_Basics/How to format seconds.java b/java/_Basics/How to format seconds.java deleted file mode 100644 index 24975fb..0000000 --- a/java/_Basics/How to format seconds.java +++ /dev/null @@ -1,9 +0,0 @@ - import java.text.SimpleDateFormat; - import java.util.Date; - public class Main { - public static void main(String[] args) { - Date date = new Date(); - SimpleDateFormat sdf = new SimpleDateFormat("ss"); - System.out.println("seconds in ss format : "+ sdf.format(date)); - } - } \ No newline at end of file diff --git a/java/_Basics/How to format time in 24 hour format.java b/java/_Basics/How to format time in 24 hour format.java deleted file mode 100644 index aa5743e..0000000 --- a/java/_Basics/How to format time in 24 hour format.java +++ /dev/null @@ -1,9 +0,0 @@ - import java.text.SimpleDateFormat; - import java.util.Date; - public class Main { - public static void main(String[] args) { - Date date = new Date(); - SimpleDateFormat sdf = new SimpleDateFormat("h"); - System.out.println("hour in h format : "+ sdf.format(date)); - } - } \ No newline at end of file diff --git a/java/_Basics/How to format time in AM-PM format.java b/java/_Basics/How to format time in AM-PM format.java deleted file mode 100644 index d5442a8..0000000 --- a/java/_Basics/How to format time in AM-PM format.java +++ /dev/null @@ -1,10 +0,0 @@ - import java.text.SimpleDateFormat; - import java.util.Date; - public class Main { - public static void main(String[] args) { - Date date = new Date(); - String strDateFormat = "HH:mm:ss a"; - SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); - System.out.println(sdf.format(date)); - } - } \ No newline at end of file diff --git a/java/_Basics/How to get a files size in bytes.java b/java/_Basics/How to get a files size in bytes.java deleted file mode 100644 index cf73c54..0000000 --- a/java/_Basics/How to get a files size in bytes.java +++ /dev/null @@ -1,16 +0,0 @@ - import java.io.File; - - public class Main { - public static long getFileSize(String filename) { - File file = new File(filename); - if (!file.exists() || !file.isFile()) { - System.out.println("File doesn\'t exist"); - return -1; - } - return file.length(); - } - public static void main(String[] args) { - long size = getFileSize("c:/java.txt"); - System.out.println("Filesize in bytes: " + size); - } - } \ No newline at end of file diff --git a/java/_Basics/How to get the maximum element from a vector.java b/java/_Basics/How to get the maximum element from a vector.java deleted file mode 100644 index dc7dec5..0000000 --- a/java/_Basics/How to get the maximum element from a vector.java +++ /dev/null @@ -1,14 +0,0 @@ - import java.util.Collections; - import java.util.Vector; - public class Main { - public static void main(String[] args) { - Vector v = new Vector(); - v.add(new Double("3.4324")); - v.add(new Double("3.3532")); - v.add(new Double("3.342")); - v.add(new Double("3.349")); - v.add(new Double("2.3")); - Object obj = Collections.max(v); - System.out.println("The max element is:"+obj); - } - } \ No newline at end of file diff --git a/java/_Basics/How to make a file read-only.java b/java/_Basics/How to make a file read-only.java deleted file mode 100644 index 62a308a..0000000 --- a/java/_Basics/How to make a file read-only.java +++ /dev/null @@ -1,9 +0,0 @@ - import java.io.File; - - public class Main { - public static void main(String[] args) { - File file = new File("C:/java.txt"); - System.out.println(file.setReadOnly()); - System.out.println(file.canWrite()); - } - } \ No newline at end of file diff --git a/java/_Basics/How to match regions in strings.java b/java/_Basics/How to match regions in strings.java deleted file mode 100644 index cb115dd..0000000 --- a/java/_Basics/How to match regions in strings.java +++ /dev/null @@ -1,9 +0,0 @@ - public class StringRegionMatch { - public static void main(String[] args) { - String first_str = "Welcome to Microsoft"; - String second_str = "I work with Microsoft"; - boolean match = first_str. - regionMatches(11, second_str, 12, 9); - System.out.println("first_str[11 -19] == "+ "second_str[12 - 21]:-"+ match); - } - } \ No newline at end of file diff --git a/java/_Basics/How to remove a particular character from a string.java b/java/_Basics/How to remove a particular character from a string.java deleted file mode 100644 index 462c35b..0000000 --- a/java/_Basics/How to remove a particular character from a string.java +++ /dev/null @@ -1,9 +0,0 @@ - public class Main { - public static void main(String args[]) { - String str = "this is Scanftree;; - System.out.println(removeCharAt(str, 3)); - } - public static String removeCharAt(String s, int pos) { - return s.substring(0, pos) + s.substring(pos + 1); - } - } \ No newline at end of file diff --git a/java/_Basics/How to replace a substring inside a string by another one.java b/java/_Basics/How to replace a substring inside a string by another one.java deleted file mode 100644 index 0e31fc4..0000000 --- a/java/_Basics/How to replace a substring inside a string by another one.java +++ /dev/null @@ -1,8 +0,0 @@ - public class StringReplaceEmp { - public static void main(String args[]) { - String str="Hello World"; - System.out.println( str.replace( 'H','W' ) ); - System.out.println( str.replaceFirst("He", "Wa") ); - System.out.println( str.replaceAll("He", "Ha") ); - } - } \ No newline at end of file diff --git a/java/_Basics/How to reverse a String.java b/java/_Basics/How to reverse a String.java deleted file mode 100644 index 79f3141..0000000 --- a/java/_Basics/How to reverse a String.java +++ /dev/null @@ -1,8 +0,0 @@ - public class StringReverseExample { - public static void main(String[] args) { - String string="abcdef"; - String reverse = new StringBuffer(string).reverse().toString(); - System.out.println("\nString before reverse:"+string); - System.out.println("String after reverse:"+reverse); - } - } \ No newline at end of file diff --git a/java/_Basics/How to reverse a string using stack.java b/java/_Basics/How to reverse a string using stack.java deleted file mode 100644 index a13db54..0000000 --- a/java/_Basics/How to reverse a string using stack.java +++ /dev/null @@ -1,53 +0,0 @@ - import java.io.IOException; - public class StringReverserThroughStack { - private String input; - private String output; - public StringReverserThroughStack(String in) { - input = in; - } - public String doRev() { - int stackSize = input.length(); - Stack theStack = new Stack(stackSize); - for (int i = 0; i < input.length(); i++) { - char ch = input.charAt(i); - theStack.push(ch); - } - output = ""; - while (!theStack.isEmpty()) { - char ch = theStack.pop(); - output = output + ch; - } - return output; - } - public static void main(String[] args) - throws IOException { - String input = "Java Source and Support"; - String output; - StringReverserThroughStack theReverser = - new StringReverserThroughStack(input); - output = theReverser.doRev(); - System.out.println("Reversed: " + output); - } - class Stack { - private int maxSize; - private char[] stackArray; - private int top; - public Stack(int max) { - maxSize = max; - stackArray = new char[maxSize]; - top = -1; - } - public void push(char j) { - stackArray[++top] = j; - } - public char pop() { - return stackArray[top--]; - } - public char peek() { - return stackArray[top]; - } - public boolean isEmpty() { - return (top == -1); - } - } - } \ No newline at end of file diff --git a/java/_Basics/How to roll through hours & months.java b/java/_Basics/How to roll through hours & months.java deleted file mode 100644 index d384ff9..0000000 --- a/java/_Basics/How to roll through hours & months.java +++ /dev/null @@ -1,13 +0,0 @@ - import java.util.*; - public class Main { - public static void main(String[] args) throws Exception { - Date d1 = new Date(); - Calendar cl = Calendar. getInstance(); - cl.setTime(d1); - System.out.println("today is "+ d1.toString()); - cl. roll(Calendar.MONTH, 100); - System.out.println("date after a month will be " + cl.getTime().toString() ); - cl. roll(Calendar.HOUR, 70); - System.out.println("date after 7 hrs will be "+ cl.getTime().toString() ); - } - } \ No newline at end of file diff --git a/java/_Basics/How to search a word inside a string.java b/java/_Basics/How to search a word inside a string.java deleted file mode 100644 index 1d058ff..0000000 --- a/java/_Basics/How to search a word inside a string.java +++ /dev/null @@ -1,11 +0,0 @@ - public class SearchStringEmp { - public static void main(String[] args) { - String strOrig = "Hello readers"; - int intIndex = strOrig.indexOf("Hello"); - if(intIndex == - 1) { - System.out.println("Hello not found"); - } else { - System.out.println("Found Hello at index "+ intIndex); - } - } - } \ No newline at end of file diff --git a/java/_Basics/How to search last occurance of a substring inside a substring.java b/java/_Basics/How to search last occurance of a substring inside a substring.java deleted file mode 100644 index 30a3f9b..0000000 --- a/java/_Basics/How to search last occurance of a substring inside a substring.java +++ /dev/null @@ -1,12 +0,0 @@ - public class SearchlastString { - public static void main(String[] args) { - String strOrig = "Hello world ,Hello Reader"; - int lastIndex = strOrig.lastIndexOf("Hello"); - if(lastIndex == - 1) { - System.out.println("Hello not found"); - } else { - System.out.println("Last occurrence of Hello - is at index "+ lastIndex); - } - } - } \ No newline at end of file diff --git a/java/_Basics/How to split a string into a number of substrings.java b/java/_Basics/How to split a string into a number of substrings.java deleted file mode 100644 index e2da9c4..0000000 --- a/java/_Basics/How to split a string into a number of substrings.java +++ /dev/null @@ -1,23 +0,0 @@ - public class JavaStringSplitEmp { - public static void main(String args[]) { - String str = "jan-feb-march"; - String[] temp; - String delimeter = "-"; - temp = str.split(delimeter); - for (int i =0; i < temp.length ; i++) { - System.out.println(temp[i]); - System.out.println(""); - str = "jan.feb.march"; - delimeter = "\\."; - temp = str.split(delimeter); - } - for (int i =0; i < temp.length ; i++) { - System.out.println(temp[i]); - System.out.println(""); - temp = str.split(delimeter,2); - for (int j =0; j < temp.length ; j++) { - System.out.println(temp[i]); - } - } - } - } \ No newline at end of file diff --git a/java/_Basics/How to swap two elements in a vector.java b/java/_Basics/How to swap two elements in a vector.java deleted file mode 100644 index f4be559..0000000 --- a/java/_Basics/How to swap two elements in a vector.java +++ /dev/null @@ -1,16 +0,0 @@ - import java.util.Collections; - import java.util.Vector; - public class Main { - public static void main(String[] args) { - Vector v = new Vector(); - v.add("1"); - v.add("2"); - v.add("3"); - v.add("4"); - v.add("5"); - System.out.println(v); - Collections.swap(v, 0, 4); - System.out.println("After swapping"); - System.out.println(v); - } - } \ No newline at end of file diff --git a/java/_Basics/How to swap two numbers without using temporary variable.java b/java/_Basics/How to swap two numbers without using temporary variable.java deleted file mode 100644 index 6e4f4f2..0000000 --- a/java/_Basics/How to swap two numbers without using temporary variable.java +++ /dev/null @@ -1,16 +0,0 @@ - package com.scanftree.algos; - public class MySwapingTwoNumbers { - public static void main(String a[]) { - int x = 10; - int y = 20; - System.out.println("Before swap:"); - System.out.println("x value: "+x); - System.out.println("y value: "+y); - x = x+y; - y=x-y; - x=x-y; - System.out.println("After swap:"); - System.out.println("x value: "+x); - System.out.println("y value: "+y); - } - } \ No newline at end of file diff --git a/java/_Basics/If Else Statement.java b/java/_Basics/If Else Statement.java deleted file mode 100644 index 37d851d..0000000 --- a/java/_Basics/If Else Statement.java +++ /dev/null @@ -1,46 +0,0 @@ -If Else Statement - - - -public class IfElseStatement { - public static void main( String[] args ) { - boolean single = false; - boolean tall = true; - - // one way - if( single ) - System.out.println( "i am single" ); - - // recommended - if( single ) { - System.out.println( "i am single" ); - } - - // one way - if( single ) - System.out.println( "i am single" ); - else - System.out.println( "i am not single" ); - - // recommended - if( single ) { - System.out.println( "i am single" ); - } - else { - System.out.println( "i am not single" ); - System.out.println( "...but sometimes..." ); - } - - // note that there can be any number of - // if...else if statements - if( single == true ) { - System.out.println( "i am single" ); - } - else if( single == false && tall ) { - System.out.println( "tall, non-single man" ); - } - else { - System.out.println( "and all the rest..." ); - } - } -} diff --git a/java/_Basics/InsertionSort (Java).java b/java/_Basics/InsertionSort (Java).java deleted file mode 100644 index 6dde7b8..0000000 --- a/java/_Basics/InsertionSort (Java).java +++ /dev/null @@ -1,35 +0,0 @@ -public class InsertionSortExample -{ - public static void insertionSort(int array[]) - { - int n = array.length; - for (int j = 1; j < n; j++) - { - int key = array[j]; - int i = j-1; - while ( (i > -1) && ( array [i] > key ) ) - { - array [i+1] = array [i]; - i--; - } - array[i+1] = key; - } - } - - public static void main(String a[]) - { - int[] arr1 = {9,14,3,2,43,11,58,22}; - System.out.println("Before Insertion Sort"); - for(int i:arr1) - { - System.out.print(i+" "); - } - System.out.println(); - insertionSort(arr1);//sorting array using insertion sort - System.out.println("After Insertion Sort"); - for(int i:arr1) - { - System.out.print(i+" "); - } - } -} \ No newline at end of file diff --git a/java/_Basics/Integers.java b/java/_Basics/Integers.java deleted file mode 100644 index c36dcc8..0000000 --- a/java/_Basics/Integers.java +++ /dev/null @@ -1,215 +0,0 @@ -package com.jwetherell.algorithms.numbers; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; - -public class Integers { - - private static final BigDecimal ZERO = new BigDecimal(0); - private static final BigDecimal TWO = new BigDecimal(2); - - public static final String toBinaryUsingDivideAndModulus(int numberToConvert) { - int integer = numberToConvert; - if (integer<0) throw new IllegalArgumentException("Method argument cannot be negative. number="+integer); - StringBuilder builder = new StringBuilder(); - int temp = 0; - while (integer > 0) { - temp = integer; - integer = temp / 2; - builder.append(temp % 2); - } - return builder.reverse().toString(); - } - - public static final String toBinaryUsingShiftsAndModulus(int numberToConvert) { - int integer = numberToConvert; - if (integer<0) throw new IllegalArgumentException("Method argument cannot be negative. number="+integer); - StringBuilder builder = new StringBuilder(); - int temp = 0; - while (integer > 0) { - temp = integer; - integer = (temp >> 1); - builder.append(temp % 2); - } - return builder.reverse().toString(); - } - - public static final String toBinaryUsingBigDecimal(int numberToConvert) { - int integer = numberToConvert; - if (integer<0) throw new IllegalArgumentException("Method argument cannot be negative. number="+integer); - StringBuilder builder = new StringBuilder(); - BigDecimal number = new BigDecimal(integer); - BigDecimal[] decimals = null; - while (number.compareTo(ZERO) > 0) { - decimals = number.divideAndRemainder(TWO); - number = decimals[0]; - builder.append(decimals[1]); - } - return builder.reverse().toString(); - } - - public static final String toBinaryUsingDivideAndDouble(int numberToConvert) { - int integer = numberToConvert; - if (integer<0) throw new IllegalArgumentException("Method argument cannot be negative. number="+integer); - StringBuilder builder = new StringBuilder(); - double temp = 0d; - while (integer > 0) { - temp = integer/2d; - integer = (int) temp; - builder.append((temp > integer) ? 1 : 0); - } - return builder.reverse().toString(); - } - - public static final boolean powerOfTwoUsingLoop(int numberToCheck) { - int number = numberToCheck; - if (number == 0) - return false; - while (number % 2 == 0) { - number /= 2; - } - if (number > 1) - return false; - return true; - } - - public static final boolean powerOfTwoUsingRecursion(int numberToCheck) { - int number = numberToCheck; - if (number == 1) - return true; - if (number == 0 || number % 2 != 0) - return false; - return powerOfTwoUsingRecursion(number / 2); - } - - public static final boolean powerOfTwoUsingLog(int numberToCheck) { - int number = numberToCheck; - double doubleLog = Math.log10(number) / Math.log10(2); - int intLog = (int) doubleLog; - if (doubleLog == intLog) - return true; - return false; - } - - public static final boolean powerOfTwoUsingBits(int numberToCheck) { - int number = numberToCheck; - if (number != 0 && ((number & (number - 1)) == 0)) - return true; - return false; - } - - // Integer to English - private static final Map singleDigits = new HashMap(); - static { - singleDigits.put(0,"zero"); - singleDigits.put(1,"one"); - singleDigits.put(2,"two"); - singleDigits.put(3,"three"); - singleDigits.put(4,"four"); - singleDigits.put(5,"five"); - singleDigits.put(6,"six"); - singleDigits.put(7,"seven"); - singleDigits.put(8,"eight"); - singleDigits.put(9,"nine"); - singleDigits.put(10,"ten"); - singleDigits.put(11,"eleven"); - singleDigits.put(12,"twelve"); - singleDigits.put(13,"thirteen"); - singleDigits.put(14,"fourteen"); - singleDigits.put(15,"fifteen"); - singleDigits.put(16,"sixteen"); - singleDigits.put(17,"seventee"); - singleDigits.put(18,"eighteen"); - singleDigits.put(19,"nineteen"); - } - - private static final Map multiDigits = new HashMap(); - static { - multiDigits.put(10,"ten"); - multiDigits.put(20,"twenty"); - multiDigits.put(30,"thirty"); - multiDigits.put(40,"fourty"); - multiDigits.put(50,"fifty"); - multiDigits.put(60,"sixty"); - multiDigits.put(70,"seventy"); - multiDigits.put(80,"eighty"); - multiDigits.put(90,"ninty"); - } - - private static final int BILLION = 1000000000; - private static final int MILLION = 1000000; - private static final int THOUSAND = 1000; - private static final int HUNDRED = 100; - private static final int TEN = 10; - - private static final String handleUnderOneThousand(int number) { - StringBuilder builder = new StringBuilder(); - int x = number; - int m = x / HUNDRED; - int r = x % HUNDRED; - if (m > 0) { - builder.append(singleDigits.get(m)).append("-hundred"); - x = x % HUNDRED; - } - if (r > 0) { - if (m > 0) builder.append(" "); - if (x <= 19) { - builder.append(singleDigits.get(x)); - } else { - m = x / TEN; - r = x % TEN; - if (r == 0) { - builder.append(multiDigits.get(x)); - } else { - x = x - r; - builder.append(multiDigits.get(x)).append("-"); - builder.append(singleDigits.get(r)); - } - } - } - return builder.toString(); - } - - public static final String toEnglish(int number) { - int x = number; - if (x>Integer.MAX_VALUE || x<=Integer.MIN_VALUE) throw new IllegalArgumentException("Number has to be <= Integer.MAX_VALUE and > Integer.MIN_VALUE. number="+x); - StringBuilder builder = new StringBuilder(); - if (x==0) { - //Zero is a special case - builder.append(singleDigits.get(x)); - return builder.toString(); - } - boolean billion = false; - boolean million = false; - boolean thousand = false; - if (x<0) { - builder.append("negative "); - // Make the number positive - x = x * -1; - } - int m = x / BILLION; - if (m > 0) { - billion = true; - builder.append(handleUnderOneThousand(m)).append("-billion"); - x = x % BILLION; - } - m = x / MILLION; - if (m > 0) { - if (billion) builder.append(" "); - million = true; - builder.append(handleUnderOneThousand(m)).append("-million"); - x = x % MILLION; - } - m = x / THOUSAND; - if (m > 0) { - if (billion || million) builder.append(" "); - thousand = true; - builder.append(handleUnderOneThousand(m)).append("-thousand"); - x = x % THOUSAND; - } - if (billion || million || thousand && x!=0) builder.append(" "); - builder.append(handleUnderOneThousand(x)); - return builder.toString(); - } -} diff --git a/java/_Basics/Java Doc Comments.java b/java/_Basics/Java Doc Comments.java deleted file mode 100644 index 4e3ddd0..0000000 --- a/java/_Basics/Java Doc Comments.java +++ /dev/null @@ -1,40 +0,0 @@ -Java Doc Comments - - - - - -public class JavaDocComments { - - /** - * The execute method does blah blah - * - * @param min the min variable is this - * @param max the max variable is that - * @return String the process name - * @throws java.lang.NullPointerException reports any problems trying to execute process - */ - public String execute( int min, String max ) throws NullPointerException { - return null; - } - - /** - * outputs something like this for the execute method - - execute - - public String execute(int min, String max) - - The execute method does blah blah - - Parameters: - min - the min variable is this - max - the max variable is that - - Returns: - String the process name - - Throws: - NullPointerException - reports any problems trying to execute process - */ -} diff --git a/java/_Basics/Java program to convert Fahrenheit to Celsius.java b/java/_Basics/Java program to convert Fahrenheit to Celsius.java deleted file mode 100644 index 8bb8b6d..0000000 --- a/java/_Basics/Java program to convert Fahrenheit to Celsius.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.*; - -class FahrenheitToCelsius -{ - public static void main(String[] args) - { - float temperatue; - Scanner in = new Scanner(System.in); - System.out.println("Enter temperatue in Fahrenheit"); - temperatue = in.nextInt(); - temperatue = ((temperatue - 32)*5)/9; - System.out.println("Temperatue in Celsius = " + temperatue); - } -} \ No newline at end of file diff --git a/java/_Basics/Java program to display Current date and time.java b/java/_Basics/Java program to display Current date and time.java deleted file mode 100644 index d827ba8..0000000 --- a/java/_Basics/Java program to display Current date and time.java +++ /dev/null @@ -1,22 +0,0 @@ - import java.util.*; - - class GetCurrentDateAndTime - { - public static void main(String args[]) - { - int day, month, year; - int second, minute, hour; - GregorianCalendar date = new GregorianCalendar(); - - day = date.get(Calendar.DAY_OF_MONTH); - month = date.get(Calendar.MONTH); - year = date.get(Calendar.YEAR); - - second = date.get(Calendar.SECOND); - minute = date.get(Calendar.MINUTE); - hour = date.get(Calendar.HOUR); - - System.out.println("Current date is "+day+"/"+(month+1)+"/"+year); - System.out.println("Current time is "+hour+" : "+minute+" : "+second); - } - } \ No newline at end of file diff --git a/java/_Basics/Java program to find all substrings of a string.java b/java/_Basics/Java program to find all substrings of a string.java deleted file mode 100644 index 66bd25e..0000000 --- a/java/_Basics/Java program to find all substrings of a string.java +++ /dev/null @@ -1,23 +0,0 @@ -import java.util.Scanner; - -class SubstringsOfAString -{ - public static void main(String args[]) - { - String string, sub; - int i, c, length; - Scanner in = new Scanner(System.in); - System.out.println("Enter a string to print it's all substrings"); - string = in.nextLine(); - length = string.length(); - System.out.println("Substrings of \""+string+"\" are :-"); - for( c = 0 ; c < length ; c++ ) - { - for( i = 1 ; i <= length - c ; i++ ) - { - sub = string.substring(c, c+i); - System.out.println(sub); - } - } - } -} \ No newline at end of file diff --git a/java/_Basics/Java program to perform garbage collection.java b/java/_Basics/Java program to perform garbage collection.java deleted file mode 100644 index 02c1a34..0000000 --- a/java/_Basics/Java program to perform garbage collection.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.*; - -class GarbageCollection -{ - public static void main(String s[]) throws Exception - { - Runtime rs = Runtime.getRuntime(); - System.out.println("Free memory in JVM before Garbage Collection = "+rs.freeMemory()); - rs.gc(); - System.out.println("Free memory in JVM after Garbage Collection = "+rs.freeMemory()); - } -} \ No newline at end of file diff --git a/java/_Basics/Java program to transpose matrix.java b/java/_Basics/Java program to transpose matrix.java deleted file mode 100644 index 6942967..0000000 --- a/java/_Basics/Java program to transpose matrix.java +++ /dev/null @@ -1,31 +0,0 @@ -import java.util.Scanner; - -class TransposeAMatrix -{ - public static void main(String args[]) - { - int m, n, c, d; - Scanner in = new Scanner(System.in); - System.out.println("Enter the number of rows and columns of matrix"); - m = in.nextInt(); - n = in.nextInt(); - int matrix[][] = new int[m][n]; - System.out.println("Enter the elements of matrix"); - for ( c = 0 ; c < m ; c++ ) - for ( d = 0 ; d < n ; d++ ) - matrix[c][d] = in.nextInt(); - int transpose[][] = new int[n][m]; - for ( c = 0 ; c < m ; c++ ) - { - for ( d = 0 ; d < n ; d++ ) - transpose[d][c] = matrix[c][d]; - } - System.out.println("Transpose of entered matrix:-"); - for ( c = 0 ; c < n ; c++ ) - { - for ( d = 0 ; d < m ; d++ ) - System.out.print(transpose[c][d]+"\t"); - System.out.print("\n"); - } - } -} \ No newline at end of file diff --git a/java/_Basics/KnuthMorrisPratt.java b/java/_Basics/KnuthMorrisPratt.java deleted file mode 100644 index 361ccd3..0000000 --- a/java/_Basics/KnuthMorrisPratt.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.jwetherell.algorithms.strings; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class implements KMP algorithm for finding length of maximal prefix-suffix for each prefix of the string. - * Prefix-suffix of string S is a substring which occurs at the beginning and at the end of S. - *

- * Time complexity: O(n)
- *
- * https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm - *
- * @author Szymon Stankiewicz - * @author Justin Wetherell - */ -public class KnuthMorrisPratt { - - private KnuthMorrisPratt() {} - - /** - * This function implements KMP algorithm for finding length of maximal prefix-suffix for each prefix of the string. - * Prefix-suffix of string S is a substring which occurs at the beginning and at the end of S. - *

- * Time complexity: O(n)

- *

- * https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm - *
- * @param text Text - * @return maximal length of prefix-suffix for each prefix of the string text - */ - public static List getPrefSufTable(String text) { - final List prefSufTable = new ArrayList(); - final char[] chars = text.toCharArray(); - - if (text.length() == 0) - return prefSufTable; - - prefSufTable.add(0); - - for (int i = 1; i 0 && (chars[i] != chars[sizeOfPrefSuf])) - sizeOfPrefSuf = prefSufTable.get(sizeOfPrefSuf-1); // because string is 0-indexed - - // if characters at this positions are different then sizeOfPrefSuf is equal to zero, - // so there is no proper prefix-suffix - if (chars[i] == chars[sizeOfPrefSuf]) { - prefSufTable.add(sizeOfPrefSuf+1); - } else { - prefSufTable.add(0); - } - } - return prefSufTable; - } -} diff --git a/java/_Basics/Letter combinations recursion.java b/java/_Basics/Letter combinations recursion.java deleted file mode 100644 index 3036d9c..0000000 --- a/java/_Basics/Letter combinations recursion.java +++ /dev/null @@ -1,31 +0,0 @@ -Letter combinations recursion - - - - - -public class LetterCombinationsRecursion { - - private static String sum = ""; - - public static void main( String[] argv ) { - long l = System.currentTimeMillis(); - printAlphabetCombinations( 4, "" ); - System.out.println( "Time:" + ( System.currentTimeMillis() - l ) / 1000 + " sec" ); - } - - public static void printAlphabetCombinations( int recurseCounter, String current ) { - String temp = current; - if( recurseCounter == 0 ) { - System.out.println( temp ); - return; - } - else { - recurseCounter--; - for( int i = 0; i < 26; i++ ) { - temp = current + (char) ( 65 + i ); - printAlphabetCombinations( recurseCounter, temp ); - } - } - } -} diff --git a/java/_Basics/Listing all running threads.java b/java/_Basics/Listing all running threads.java deleted file mode 100644 index 5eadcaf..0000000 --- a/java/_Basics/Listing all running threads.java +++ /dev/null @@ -1,42 +0,0 @@ -Listing all running threads - -// Find the root thread group -ThreadGroup root = Thread.currentThread().getThreadGroup().getParent(); - while (root.getParent() != null) { - root = root.getParent(); -} - -// Visit each thread group -visit(root, 0); - -// This method recursively visits all thread groups under `group'. - public static void visit(ThreadGroup group, int level) { - // Get threads in `group' - int numThreads = group.activeCount(); - Thread[] threads = new Thread[numThreads*2]; - numThreads = group.enumerate(threads, false); - - // Enumerate each thread in `group' - for (int i=0; i // Get thread - Thread thread = threads[i]; - } - - // Get thread subgroups of `group' - int numGroups = group.activeGroupCount(); - ThreadGroup[] groups = new ThreadGroup[numGroups*2]; - numGroups = group.enumerate(groups, false); - - // Recursively visit each subgroup - for (int i=0; i visit(groups[i], level+1); - } -} - -//Here's an example of some thread groups that contain some threads: -java.lang.ThreadGroup[name=system,maxpri=10] -Thread[Reference Handler,10,system] -Thread[Finalizer,8,system] -Thread[Signal Dispatcher,10,system] -Thread[CompileThread0,10,system] -java.lang.ThreadGroup[name=main,maxpri=10] -Thread[main,5,main] -Thread[Thread-1,5,main] diff --git a/java/_Basics/LongestCommonSubsequence.java b/java/_Basics/LongestCommonSubsequence.java deleted file mode 100644 index fa807cd..0000000 --- a/java/_Basics/LongestCommonSubsequence.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.jwetherell.algorithms.sequence; - -import java.util.HashSet; -import java.util.Set; - -/** - * The longest common subsequence (LCS) problem is the problem of finding the longest subsequence common to all sequences in a set of sequences (often just two sequences). It differs from problems - * of finding common substrings: unlike substrings, subsequences are not required to occupy consecutive positions within the original sequences. - *

- * https://en.wikipedia.org/wiki/Longest_common_subsequence_problem - *
- * @author Justin Wetherell - */ -@SuppressWarnings("unchecked") -public class LongestCommonSubsequence { - - private static int[][] lengthMatrix = null; - private static Set[][] sequenceMatrix = null; - - private LongestCommonSubsequence() { } - - public static MatrixPair getLCS(char[] seq1, char[] seq2) { - try { - populateMatrix(seq1, seq2); - - for (int i = 0; i < seq1.length; i++) { - for (int j = 0; j < seq2.length; j++) { - lengthMatrix[i + 1][j + 1] = longestCommonSubsequence(i, j, seq1, seq2); - } - } - - return (new MatrixPair(lengthMatrix, sequenceMatrix)); - } finally { - lengthMatrix = null; - sequenceMatrix = null; - } - } - - private static void populateMatrix(char[] seq1, char[] seq2) { - lengthMatrix = new int[seq1.length + 1][seq2.length + 1]; - sequenceMatrix = new HashSet[seq1.length][seq2.length]; - } - - private static int longestCommonSubsequence(int i, int j, char[] seq1, char[] seq2) { - char x = seq1[i]; - char y = seq2[j]; - int result = 0; - Set set = sequenceMatrix[i][j]; - if (set == null) - set = new HashSet(); - if (x == y) { - if (i > 0 && j > 0) - set = new HashSet(sequenceMatrix[i - 1][j - 1]); - distribute(x, set); - - result = (lengthMatrix[i][j]) + 1; - } else { - int a = lengthMatrix[i][j + 1]; - int b = lengthMatrix[i + 1][j]; - - if (a > b) { - set = new HashSet(sequenceMatrix[i - 1][j]); - - result = a; - } else if (b > a) { - set = new HashSet(sequenceMatrix[i][j - 1]); - - result = b; - } else if (a == b) { - if (i > 0 && j > 0) { - Set list1 = sequenceMatrix[i - 1][j]; - Set list2 = sequenceMatrix[i][j - 1]; - - set.addAll(list1); - set.addAll(list2); - } - - result = a; // a==b - } - } - sequenceMatrix[i][j] = set; - return result; - } - - private static void distribute(char c, Set set) { - if (set.size() == 0) { - set.add(String.valueOf(c)); - } else { - Object[] strings = set.toArray(); - set.clear(); - for (Object object : strings) { - String string = (String) object; - String seq = String.valueOf(c); - if (!string.contains(seq)) - string = string.concat(seq); - set.add(string); - } - } - } - - public static class MatrixPair { - - private int[][] lenMatrix = null; - private Set[][] seqMatrix = null; - - public MatrixPair(int[][] lengthMatrix, Set[][] sequenceMatrix) { - this.lenMatrix = lengthMatrix; - this.seqMatrix = sequenceMatrix; - } - - public int getLongestSequenceLength() { - if (lenMatrix == null) - return 0; - - int length1 = lenMatrix.length; - int length2 = lenMatrix[length1 - 1].length; - return lenMatrix[length1 - 1][length2 - 1]; - } - - public Set getLongestSequences() { - if (seqMatrix == null) - return (new HashSet()); - - int length1 = seqMatrix.length; - int length2 = seqMatrix[length1 - 1].length; - return seqMatrix[length1 - 1][length2 - 1]; - } - - public int[][] getLengthMatrix() { - return lenMatrix; - } - - public Set[][] getSequenceMatrix() { - return seqMatrix; - } - - public String getLengthMatrixString() { - StringBuilder builder = new StringBuilder(); - if (lenMatrix == null) { - builder.append("Length matrix is NULL.\n"); - } else { - for (int i = 0; i < lenMatrix.length; i++) { - int length = lenMatrix[i].length; - for (int j = 0; j < length; j++) { - int size = lenMatrix[i][j]; - builder.append(size); - if (j < length - 1) - builder.append(",\t"); - } - builder.append("\n"); - } - } - return builder.toString(); - } - - public String getSequenceMatrixString() { - StringBuilder builder = new StringBuilder(); - if (seqMatrix == null) { - builder.append("Sequence matrix is NULL.\n"); - } else { - for (int i = 0; i < seqMatrix.length; i++) { - int length = seqMatrix[i].length; - for (int j = 0; j < length; j++) { - Set set = seqMatrix[i][j]; - builder.append(set.toString()); - if (j < length - 1) - builder.append(", "); - } - builder.append("\n"); - } - } - return builder.toString(); - } - } -} diff --git a/java/_Basics/LongestIncreasingSubsequence.java b/java/_Basics/LongestIncreasingSubsequence.java deleted file mode 100644 index cdb39de..0000000 --- a/java/_Basics/LongestIncreasingSubsequence.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.jwetherell.algorithms.sequence; - -import com.jwetherell.algorithms.search.LowerBound; - -import java.util.Arrays; - -/** - * In computer science, the longest increasing subsequence problem is to find a subsequence of a given sequence in which the subsequence's elements are in sorted order, lowest to highest, and in - * which the subsequence is as long as possible. This subsequence is not necessarily contiguous, or unique. - *

- * https://en.wikipedia.org/wiki/Longest_increasing_subsequence - *
- * @author Bartlomiej Drozd - * @author Justin Wetherell - */ -public class LongestIncreasingSubsequence { - - private LongestIncreasingSubsequence() { } - - /** - * Longest increasing subsequence solved using dynamic programming. - */ - public static int[] getLongestIncreasingSubsequence(int[] sequence) { - final int[] resultSequence = new int[sequence.length]; - - int resultLength = 0; - for (int i = 0; i < sequence.length; ++i) { - // try to find the best place for new element in sorted result - final int pos = LowerBound.lowerBound(resultSequence, resultLength, sequence[i]); //O(log n) - // if the best place is at the end increase result length - if (pos >= resultLength) - resultLength++; - resultSequence[pos] = sequence[i]; - } - - return Arrays.copyOfRange(resultSequence, 0, resultLength); - } -} diff --git a/java/_Basics/Longs.java b/java/_Basics/Longs.java deleted file mode 100644 index e3f1f3d..0000000 --- a/java/_Basics/Longs.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.jwetherell.algorithms.numbers; - -import java.math.BigDecimal; - -public class Longs { - - public static final String toBinaryUsingDivideAndModulus(long numberToConvert) { - long longNumber = numberToConvert; - if (longNumber<0) throw new IllegalArgumentException("Method argument cannot be negative. number="+longNumber); - StringBuilder builder = new StringBuilder(); - long temp = 0l; - while (longNumber > 0) { - temp = longNumber; - longNumber = temp / 2; - builder.append(temp % 2); - } - return builder.reverse().toString(); - } - - public static final String toBinaryUsingShiftsAndModulus(long numberToConvert) { - long longNumber = numberToConvert; - if (longNumber<0) throw new IllegalArgumentException("Method argument cannot be negative. number="+longNumber); - StringBuilder builder = new StringBuilder(); - long temp = 0l; - while (longNumber > 0) { - temp = longNumber; - longNumber = (temp >> 1); - builder.append(temp % 2); - } - return builder.reverse().toString(); - } - - public static final String toBinaryUsingBigDecimal(long numberToConvert) { - long longNumber = numberToConvert; - if (longNumber<0) throw new IllegalArgumentException("Method argument cannot be negative. number="+longNumber); - StringBuilder builder = new StringBuilder(); - BigDecimal zero = new BigDecimal(0); - BigDecimal two = new BigDecimal(2); - BigDecimal number = new BigDecimal(longNumber); - BigDecimal[] decimals = null; - while (number.compareTo(zero) > 0) { - decimals = number.divideAndRemainder(two); - number = decimals[0]; - builder.append(decimals[1]); - } - return builder.reverse().toString(); - } -} diff --git a/java/_Basics/Multiple Inheritance.java b/java/_Basics/Multiple Inheritance.java deleted file mode 100644 index 2b51092..0000000 --- a/java/_Basics/Multiple Inheritance.java +++ /dev/null @@ -1,28 +0,0 @@ -Multiple Inheritance - - - - - -import java.io.Serializable; -import java.rmi.Remote; -import java.util.Vector; - -public class MultipleInheritance - extends Vector - implements Remote, Serializable { - /** - * Java is a single inheritance tree and only allows a - * class to inherit implementation from one class. That - * class is specified using extends (eg. Vector ) otherwise - * if nothing is specified it is Object, the root class in - * the Java inheritance hierarchy - *

- * However, Java does support the multiple interface inheritance. - * In this example we inheritance from both the Remote and Serializable - * interfaces. - */ - public static void main( String[] args ) { - - } -} diff --git a/java/_Basics/Null Reference.java b/java/_Basics/Null Reference.java deleted file mode 100644 index baabd87..0000000 --- a/java/_Basics/Null Reference.java +++ /dev/null @@ -1,33 +0,0 @@ -Null Reference - - - - - -import com.ack.learning.examples.account.Account; - -public class NullReference { - public static void main( String[] args ) { - // unitialised variables - String x; - Account y; - - /** - * this is an error because x is unitialised - if( x == null ) - { - - } - */ - - // initialised variables - String hsbc = null; - Account account = null; - - // object arrays are initialised to null - String[] names = new String[5]; - for( int i = 0; i < names.length; i++ ) { - System.out.println( names[i] ); - } - } -} diff --git a/java/_Basics/Palindrome (Java).java b/java/_Basics/Palindrome (Java).java deleted file mode 100644 index b773622..0000000 --- a/java/_Basics/Palindrome (Java).java +++ /dev/null @@ -1,19 +0,0 @@ -class PalindromeExample -{ - public static void main(String args[]) - { - int r,sum=0,temp; - int n=454;//It is the number variable to be checked for palindrome - temp=n; - while(n>0) - { - r=n%10; //getting remainder - sum=(sum*10)+r; - n=n/10; - } - if(temp==sum) - System.out.println("palindrome number "); - else - System.out.println("not palindrome"); - } -} \ No newline at end of file diff --git a/java/_Basics/Pie Eater.java b/java/_Basics/Pie Eater.java deleted file mode 100644 index 1c32696..0000000 --- a/java/_Basics/Pie Eater.java +++ /dev/null @@ -1,21 +0,0 @@ -Pie Eater - - - -package com.ack.learning.exceptions; - -public class PieEater { - private int piesEaten; - - // the throws clause tells use that this method - // can throw a PieException - public int howManyPies() throws PieException { - // do some processing - if( piesEaten > 100 ) { - // create a PieException object and throw it - throw new PieException( "he's eaten all the pies" ); - } - - return piesEaten; - } -} diff --git a/java/_Basics/Pie Maker.java b/java/_Basics/Pie Maker.java deleted file mode 100644 index 756343f..0000000 --- a/java/_Basics/Pie Maker.java +++ /dev/null @@ -1,27 +0,0 @@ -Pie Maker - - - -package com.ack.learning.exceptions; - -import com.ack.learning.exceptions.PieEater; -import com.ack.learning.exceptions.PieException; - -public class PieMaker { - public static void main( String[] args ) { - try { - PieEater pie = new PieEater(); - // some processing - System.out.println( pie.howManyPies() ); - } - catch( PieException pex ) { - // catch the PieException and printout its stack trace - pex.printStackTrace(); - } - finally { - // and always print out 'no more pies', regardless of what - // happens within the try block - System.out.println( "no more pies" ); - } - } -} diff --git a/java/_Basics/Pie exception.java b/java/_Basics/Pie exception.java deleted file mode 100644 index 200e2be..0000000 --- a/java/_Basics/Pie exception.java +++ /dev/null @@ -1,16 +0,0 @@ -Pie exception - - - -package com.ack.learning.exceptions; - -// define your own exception by extending java.lang.Exception - -public class PieException extends Exception { - // let this exception accept a user message that can be - // accessed through calling getMessage() that is defined - // within its parent class - public PieException( String msg ) { - super( msg ); - } -} diff --git a/java/_Basics/Pre and post increment operators.java b/java/_Basics/Pre and post increment operators.java deleted file mode 100644 index c36a500..0000000 --- a/java/_Basics/Pre and post increment operators.java +++ /dev/null @@ -1,34 +0,0 @@ -Pre and post increment operators - - - - - -public class PreAndPostIncrementOperators { - public static void main( String[] args ) { - int index = 0; - - // all these statements add one to index - index = index + 1; - index += 1; - index++; - ++index; - - // prints index value -> 4 - System.out.println( index ); - - // prints index current value of 4, and then increments - System.out.println( index++ ); - - // prints index value which is 5 - System.out.println( index ); - - // increments index, and then prints its value of 6 - System.out.println( ++index ); - - // prints out current value of index which is 6 - System.out.println( index ); - - // same logic holds for -- operator - } -} diff --git a/java/_Basics/Program for converting numbers in a file to corres.java b/java/_Basics/Program for converting numbers in a file to corres.java deleted file mode 100644 index 9244787..0000000 --- a/java/_Basics/Program for converting numbers in a file to corres.java +++ /dev/null @@ -1,114 +0,0 @@ -Program for converting numbers in a file to corresponding words - -import java.io.*; -import java.lang.*; - -class NumToWords -{ - public static void main(String a[]) throws IOException - { - String s=""; - BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); - System.out.print("Enter filename : "); - try - { - s=br.readLine(); - }catch(Exception e){} - InputStream in=new FileInputStream(s); - MyInputStream mis=new MyInputStream(in); - mis.changeNumbers(); - in.close(); - mis.close(); - } -} -class MyInputStream extends FilterInputStream -{ - InputStream is; - MyInputStream(InputStream in) - { - super(in); - is=in; - } - public void changeNumbers() throws IOException - { - PushbackInputStream pis; - String num=""; - char ch; - int c; - pis=new PushbackInputStream(is); - while((c=pis.read())!=-1) - { - ch=(char)c; - if('0'<=ch&&ch<='9') - { - num=""; - while('0'<=ch&&ch<='9'&&c!=-1) - { - num=num+ch; - c=pis.read(); - ch=(char)c; - } - System.out.print(MyInputStream.process(num)); - pis.unread(ch); - } - else - System.out.print(ch); - } - } - static String process(String str) - { - String a1[]={"One","Two","Three","Four","Five","Six","Seven","Eight","Nine"}; - String a2[]={"Twenty","Thirty","Fourty","Fifty","Sixty","Seventy","Eighty","Ninety"}; - String a3[]={"Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"}; - String a4[]={"Hundered","Thousand","Lakhs","Crores"}; - int num=0; - try - { - num=Integer.parseInt(str); - }catch(Exception e){} - if(num==0) - return "Zero"; - int n,n1; - String ans=""; - String ans1=""; - n1=num%10; - num=num/10; - if(n1!=0) - ans=a1[n1-1]; - if(num>0) - { - n=num%10; - num=num/10; - if(n==1) - ans=a3[n1]; - else if(n!=0) - ans=a2[n-2]+" "+ans; - } - if(num>0) - { - n=num%10; - num=num/10; - if(n!=0) - ans=a1[n-1]+" "+a4[0]+" "+ans; - } - for(int i=1;num>0;i++) - { - n1=num%10; - num=num/10; - if(n1!=0) - ans1=a1[n1-1]; - if(num>0) - { - n=num%10; - num=num/10; - if(n==1) - ans1=a3[n1]; - else if(n!=0) - ans1=a2[n-2]+" "+ans1; - } - ans=ans1+" "+a4[i]+" "+ans; - ans1=""; - } - return(ans); - } -} diff --git a/java/_Basics/Program for counting no.java b/java/_Basics/Program for counting no.java deleted file mode 100644 index ae8ffcd..0000000 --- a/java/_Basics/Program for counting no.java +++ /dev/null @@ -1,35 +0,0 @@ -Program for counting no. of Chars, Words and Lines in a file - -import java.lang.*; -import java.io.*; -import java.util.*; -class WordCount -{ - public static void main(String arg[]) throws Exception - { - int char_count=0; - int word_count=0; - int line_count=0; - String s; - StringTokenizer st; - BufferedReader buf=new BufferedReader(new InputStreamReader(System.in)); - System.out.print("Enter filename : "); - s=buf.readLine(); - buf=new BufferedReader(new FileReader(s)); - while((s=buf.readLine())!=null) - { - line_count++; - st=new StringTokenizer(s," ,;:."); - while(st.hasMoreTokens()) - { - word_count++; - s=st.nextToken(); - char_count+=s.length(); - } - } - System.out.println("Character Count : "+char_count); - System.out.println("Word Count : "+word_count); - System.out.println("Line Count : "+line_count); - buf.close(); - } -} diff --git a/java/_Basics/Program to Add of two matrices (Java).java b/java/_Basics/Program to Add of two matrices (Java).java deleted file mode 100644 index b2c37b4..0000000 --- a/java/_Basics/Program to Add of two matrices (Java).java +++ /dev/null @@ -1,36 +0,0 @@ -import java.util.Scanner; - -class Add2Matrix -{ - - public static void main(String args[]) - { - int rows, cols, c, d; - Scanner in = new Scanner(System.in); - System.out.println("Please Enter number of rows and columns"); - rows = in.nextInt(); - cols = in.nextInt(); - int first[][] = new int[rows][cols]; - int second[][] = new int[rows][cols]; - int sum[][] = new int[rows][cols]; - System.out.println("Please Enter elements of first matrix"); - for ( c = 0 ; c < rows ; c++ ) - for ( d = 0 ; d < cols ; d++ ) - first[c][d] = in.nextInt(); - System.out.println("Please Enter elements of second matrix"); - for ( c = 0 ; c < rows ; c++ ) - for ( d = 0 ; d < cols ; d++ ) - second[c][d] = in.nextInt(); - for ( c = 0 ; c < rows ; c++ ) - for ( d = 0 ; d < cols ; d++ ) - sum[c][d] = first[c][d] + second[c][d]; //replace '+' with '-' to subtract matrices - System.out.println("Sum of entered matrices:-"); - for ( c = 0 ; c < rows ; c++ ) - { - for ( d = 0 ; d < cols ; d++ ) - System.out.print(sum[c][d]+"\t"); - System.out.println(); - } - } - -} diff --git a/java/_Basics/Program to Calculate Circle Area (Java).java b/java/_Basics/Program to Calculate Circle Area (Java).java deleted file mode 100644 index 0563645..0000000 --- a/java/_Basics/Program to Calculate Circle Area (Java).java +++ /dev/null @@ -1,51 +0,0 @@ -/* - Calculate Circle Area using Java Example - This Calculate Circle Area using Java Example shows how to calculate - area of circle using it's radius. -*/ - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -public class CalculateCircleAreaExample -{ - - public static void main(String[] args) - { - int radius = 0; - System.out.println("Please enter radius of a circle"); - try - { - //get the radius from console - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - radius = Integer.parseInt(br.readLine()); - } - //if invalid value was entered - catch(NumberFormatException ne) - { - System.out.println("Invalid radius value" + ne); - System.exit(0); - } - catch(IOException ioe) - { - System.out.println("IO Error :" + ioe); - System.exit(0); - } - /* - * Area of a circle is - * pi * r * r - * where r is a radius of a circle. - */ - //NOTE : use Math.PI constant to get value of pi - double area = Math.PI * radius * radius; - System.out.println("Area of a circle is " + area); - } -} - -/* -Output of Calculate Circle Area using Java Example would be -Please enter radius of a circle -19 -Area of a circle is 1134.1149479459152 -*/ \ No newline at end of file diff --git a/java/_Basics/Program to Calculate Circle Perimeter (Java).java b/java/_Basics/Program to Calculate Circle Perimeter (Java).java deleted file mode 100644 index 01a7a00..0000000 --- a/java/_Basics/Program to Calculate Circle Perimeter (Java).java +++ /dev/null @@ -1,51 +0,0 @@ -/* - Calculate Circle Perimeter using Java Example - This Calculate Circle Perimeter using Java Example shows how to calculate - Perimeter of circle using it's radius. -*/ - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -public class CalculateCirclePerimeterExample -{ - - public static void main(String[] args) - { - int radius = 0; - System.out.println("Please enter radius of a circle"); - try - { - //get the radius from console - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - radius = Integer.parseInt(br.readLine()); - } - //if invalid value was entered - catch(NumberFormatException ne) - { - System.out.println("Invalid radius value" + ne); - System.exit(0); - } - catch(IOException ioe) - { - System.out.println("IO Error :" + ioe); - System.exit(0); - } - /* - * Perimeter of a circle is - * 2 * pi * r - * where r is a radius of a circle. - */ - //NOTE : use Math.PI constant to get value of pi - double perimeter = 2 * Math.PI * radius; - System.out.println("Perimeter of a circle is " + perimeter); - } -} - -/* -Output of Calculate Circle Perimeter using Java Example would be -Please enter radius of a circle -19 -Perimeter of a circle is 119.38052083641213 -*/ \ No newline at end of file diff --git a/java/_Basics/Program to Calculate Rect Area (Java).java b/java/_Basics/Program to Calculate Rect Area (Java).java deleted file mode 100644 index 70a862e..0000000 --- a/java/_Basics/Program to Calculate Rect Area (Java).java +++ /dev/null @@ -1,56 +0,0 @@ -/* - Calculate Rectangle Area using Java Example - This Calculate Rectangle Area using Java Example shows how to calculate - area of Rectangle using it's length and width. -*/ - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -public class CalculateRectArea -{ - - public static void main(String[] args) - { - int width = 0; - int length = 0; - try - { - //read the length from console - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - System.out.println("Please enter length of a rectangle"); - length = Integer.parseInt(br.readLine()); - //read the width from console - System.out.println("Please enter width of a rectangle"); - width = Integer.parseInt(br.readLine()); - } - //if invalid value was entered - catch(NumberFormatException ne) - { - System.out.println("Invalid value" + ne); - System.exit(0); - } - catch(IOException ioe) - { - System.out.println("IO Error :" + ioe); - System.exit(0); - } - /* - * Area of a rectangle is - * length * width - */ - int area = length * width; - System.out.println("Area of a rectangle is " + area); - } - -} - -/* -Output of Calculate Rectangle Area using Java Example would be -Please enter length of a rectangle -10 -Please enter width of a rectangle -15 -Area of a rectangle is 150 -*/ \ No newline at end of file diff --git a/java/_Basics/Program to Calculate Rect Perimeter (Java).java b/java/_Basics/Program to Calculate Rect Perimeter (Java).java deleted file mode 100644 index faad5a6..0000000 --- a/java/_Basics/Program to Calculate Rect Perimeter (Java).java +++ /dev/null @@ -1,56 +0,0 @@ -/* - Calculate Rectangle Perimeter using Java Example - This Calculate Rectangle Perimeter using Java Example shows how to calculate - perimeter of Rectangle using it's length and width. -*/ - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -public class CalculateRectPerimeter -{ - - public static void main(String[] args) - { - int width = 0; - int length = 0; - try - { - //read the length from console - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - System.out.println("Please enter length of a rectangle"); - length = Integer.parseInt(br.readLine()); - //read the width from console - System.out.println("Please enter width of a rectangle"); - width = Integer.parseInt(br.readLine()); - } - //if invalid value was entered - catch(NumberFormatException ne) - { - System.out.println("Invalid value" + ne); - System.exit(0); - } - catch(IOException ioe) - { - System.out.println("IO Error :" + ioe); - System.exit(0); - } - /* - * Perimeter of a rectangle is - * 2 * (length + width) - */ - int perimeter = 2 * (length + width); - System.out.println("Perimeter of a rectangle is " + perimeter); - } - -} - -/* -Output of Calculate Rectangle Perimeter using Java Example would be -Please enter length of a rectangle -10 -Please enter width of a rectangle -15 -Perimeter of a rectangle is 50 -*/ \ No newline at end of file diff --git a/java/_Basics/Program to Find Even Or Odd Number (Java).java b/java/_Basics/Program to Find Even Or Odd Number (Java).java deleted file mode 100644 index 157bba2..0000000 --- a/java/_Basics/Program to Find Even Or Odd Number (Java).java +++ /dev/null @@ -1,41 +0,0 @@ -/* - Even Odd Number Example - This Java Even Odd Number Example shows how to check if the given - number is even or odd. -*/ - -public class FindEvenOrOddNumber -{ - - public static void main(String[] args) - { - //create an array of 10 numbers - int[] numbers = new int[] {1,2,3,4,5,6,7,8,9,10}; - for(int i=0; i < numbers.length; i++) - { - /* - * use modulus operator to check if the number is even or odd. - * If we divide any number by 2 and reminder is 0 then the number is - * even, otherwise it is odd. - */ - if(numbers[i]%2 == 0) - System.out.println(numbers[i] + " is even number."); - else - System.out.println(numbers[i] + " is odd number."); - } - } -} - -/* -Output of the program would be -1 is odd number. -2 is even number. -3 is odd number. -4 is even number. -5 is odd number. -6 is even number. -7 is odd number. -8 is even number. -9 is odd number. -10 is even number. -*/ \ No newline at end of file diff --git a/java/_Basics/Program to Find Largest Smallest Number (Java).java b/java/_Basics/Program to Find Largest Smallest Number (Java).java deleted file mode 100644 index 0fdc3b3..0000000 --- a/java/_Basics/Program to Find Largest Smallest Number (Java).java +++ /dev/null @@ -1,32 +0,0 @@ -/* - Find Largest and Smallest Number in an Array Example - This Java Example shows how to find largest and smallest number in an - array. -*/ -public class FindLargestSmallestNumber -{ - - public static void main(String[] args) - { - //array of 10 numbers - int numbers[] = new int[] {32,43,53,54,32,65,63,98,43,23}; - //assign first element of an array to largest and smallest - int smallest = numbers[0]; - int largetst = numbers[0]; - for(int i=1; i< numbers.length; i++) - { - if(numbers[i] > largetst) - largetst = numbers[i]; - else if (numbers[i] < smallest) - smallest = numbers[i]; - } - System.out.println("Largest Number is : " + largetst); - System.out.println("Smallest Number is : " + smallest); - } -} - -/* -Output of this program would be -Largest Number is : 98 -Smallest Number is : 23 -*/ \ No newline at end of file diff --git a/java/_Basics/Program to Find Second smallest number in java without sorting (Java).java b/java/_Basics/Program to Find Second smallest number in java without sorting (Java).java deleted file mode 100644 index 2b356a0..0000000 --- a/java/_Basics/Program to Find Second smallest number in java without sorting (Java).java +++ /dev/null @@ -1,26 +0,0 @@ - -class SecondSmallestNumber -{ - - public static void main(String args[]) - { - int numbers[] = {6,3,37,12,46,5,64,21}; - int smallest= numbers[0];; - int second_smallest = numbers[0];; - for(int n:numbers) - { - if(n< smallest) - { - second_smallest = smallest; - smallest=n; - } - else if( n< second_smallest) - { - second_smallest= n; - } - } - System.out.println("Smallest Number: "+smallest); - System.out.println("Second Smallest Number: "+second_smallest); - } - -} \ No newline at end of file diff --git a/java/_Basics/Program to Find longest substring without repeating characters (Java).java b/java/_Basics/Program to Find longest substring without repeating characters (Java).java deleted file mode 100644 index 8c8f195..0000000 --- a/java/_Basics/Program to Find longest substring without repeating characters (Java).java +++ /dev/null @@ -1,78 +0,0 @@ -/* -Given a string, find the longest substrings without repeating characters. Iterate through the given string, find the longest maximum substrings. - -*/ - -import java.util.HashSet; -import java.util.Set; - -public class MyLongestSubstr -{ - - private Set subStrList = new HashSet(); - private int finalSubStrSize = 0; - - public Set getLongestSubstr(String input) - { - //reset instance variables - subStrList.clear(); - finalSubStrSize = 0; - // have a boolean flag on each character ascii value - boolean[] flag = new boolean[256]; - int j = 0; - char[] inputCharArr = input.toCharArray(); - for (int i = 0; i < inputCharArr.length; i++) - { - char c = inputCharArr[i]; - if (flag[c]) - { - extractSubString(inputCharArr,j,i); - for (int k = j; k < i; k++) - { - if (inputCharArr[k] == c) - { - j = k + 1; - break; - } - flag[inputCharArr[k]] = false; - } - } - else - { - flag[c] = true; - } - } - extractSubString(inputCharArr,j,inputCharArr.length); - return subStrList; - } - - private String extractSubString(char[] inputArr, int start, int end) - { - StringBuilder sb = new StringBuilder(); - for(int i=start; i finalSubStrSize) - { - finalSubStrSize = subStr.length(); - subStrList.clear(); - subStrList.add(subStr); - } - else if(subStr.length() == finalSubStrSize) - { - subStrList.add(subStr); - } - return sb.toString(); - } - - public static void main(String a[]) - { - MyLongestSubstr mls = new MyLongestSubstr(); - System.out.println(mls.getLongestSubstr("java2novice")); - System.out.println(mls.getLongestSubstr("java_language_is_sweet")); - System.out.println(mls.getLongestSubstr("java_java_java_java")); - System.out.println(mls.getLongestSubstr("abcabcbb")); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to Find out duplicate number between 1 to N numbers (Java).java b/java/_Basics/Program to Find out duplicate number between 1 to N numbers (Java).java deleted file mode 100644 index df347e0..0000000 --- a/java/_Basics/Program to Find out duplicate number between 1 to N numbers (Java).java +++ /dev/null @@ -1,37 +0,0 @@ -import java.util.ArrayList; -import java.util.List; - -public class DuplicateNumber -{ - - public int findDuplicateNumber(List numbers) - { - int highestNumber = numbers.size() - 1; - int total = getSum(numbers); - int duplicate = total - (highestNumber*(highestNumber+1)/2); - return duplicate; - } - - public int getSum(List numbers) - { - int sum = 0; - for(int num:numbers) - { - sum += num; - } - return sum; - } - - public static void main(String a[]) - { - List numbers = new ArrayList(); - for(int i=1; i<30; i++) - { - numbers.add(i); - } - //add duplicate number into the list - numbers.add(22); - DuplicateNumber dn = new DuplicateNumber(); - System.out.println("Duplicate Number: "+dn.findDuplicateNumber(numbers)); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to Find out middle index where sum of both ends are equal. (Java).java b/java/_Basics/Program to Find out middle index where sum of both ends are equal. (Java).java deleted file mode 100644 index 38ebd08..0000000 --- a/java/_Basics/Program to Find out middle index where sum of both ends are equal. (Java).java +++ /dev/null @@ -1,50 +0,0 @@ -public class FindMiddleIndex -{ - - public static int findMiddleIndex(int[] numbers) throws Exception - { - int endIndex = numbers.length - 1; - int startIndex = 0; - int sumLeft = 0; - int sumRight = 0; - while (true) - { - if (sumLeft > sumRight) - { - sumRight += numbers[endIndex--]; - } - else - { - sumLeft += numbers[startIndex++]; - } - if (startIndex > endIndex) - { - if (sumLeft == sumRight) - { - break; - } - else - { - throw new Exception( - "Please pass proper array to match the requirement"); - } - } - } - return endIndex; - } - - public static void main(String a[]) - { - int[] num = { 2, 4, 4, 5, 4, 1 }; - try - { - System.out.println("Starting from index 0, adding numbers till index " - + findMiddleIndex(num) + " and"); - System.out.println("adding rest of the numbers can be equal"); - } - catch (Exception ex) - { - System.out.println(ex.getMessage()); - } - } -} \ No newline at end of file diff --git a/java/_Basics/Program to Get distinct elements from an array by avoiding duplicate elements (Java).java b/java/_Basics/Program to Get distinct elements from an array by avoiding duplicate elements (Java).java deleted file mode 100644 index a369291..0000000 --- a/java/_Basics/Program to Get distinct elements from an array by avoiding duplicate elements (Java).java +++ /dev/null @@ -1,33 +0,0 @@ -/* -The below example shows how to avoid duplicate elements from an array and disply only distinct elements. Please use only arrays to process it. -*/ - -public class MyDisticntElements -{ - - public static void printDistinctElements(int[] arr) - { - for(int i=0; i -{ - - private Node head; - - public void add(T element) - { - Node nd = new Node(); - nd.setValue(element); - System.out.println("Adding: "+element); - Node tmp = head; - while(true) - { - if(tmp == null) - { - //since there is only one element, both head and - //tail points to the same object. - head = nd; - break; - } - else if(tmp.getNextRef() == null) - { - tmp.setNextRef(nd); - break; - } - else - { - tmp = tmp.getNextRef(); - } - } - } - - public void traverse() - { - Node tmp = head; - while(true) - { - if(tmp == null) - { - break; - } - System.out.print(tmp.getValue()+"\t"); - tmp = tmp.getNextRef(); - } - } - - public void reverse() - { - System.out.println("\nreversing the linked list\n"); - Node prev = null; - Node current = head; - Node next = null; - while(current != null) - { - next = current.getNextRef(); - current.setNextRef(prev); - prev = current; - current = next; - } - head = prev; - } - - public static void main(String a[]) - { - SinglyLinkedListImpl sl = new SinglyLinkedListImpl(); - sl.add(3); - sl.add(32); - sl.add(54); - sl.add(89); - System.out.println(); - sl.traverse(); - System.out.println(); - sl.reverse(); - sl.traverse(); - } -} - -class Node implements Comparable -{ - - private T value; - private Node nextRef; - - public T getValue() - { - return value; - } - public void setValue(T value) - { - this.value = value; - } - public Node getNextRef() - { - return nextRef; - } - public void setNextRef(Node ref) - { - this.nextRef = ref; - } - @Override - public int compareTo(T arg) - { - if(arg == this.value) - { - return 0; - } - else - { - return 1; - } - } -} \ No newline at end of file diff --git a/java/_Basics/Program to ReverseNumber (Java) v2.java b/java/_Basics/Program to ReverseNumber (Java) v2.java deleted file mode 100644 index 2262229..0000000 --- a/java/_Basics/Program to ReverseNumber (Java) v2.java +++ /dev/null @@ -1,20 +0,0 @@ -public class NumberReverse -{ - - public int reverseNumber(int number) - { - int reverse = 0; - while(number != 0) - { - reverse = (reverse*10)+(number%10); - number = number/10; - } - return reverse; - } - - public static void main(String a[]) - { - NumberReverse nr = new NumberReverse(); - System.out.println("Result: "+nr.reverseNumber(17868)); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to ReverseNumber (Java).java b/java/_Basics/Program to ReverseNumber (Java).java deleted file mode 100644 index 1871e8a..0000000 --- a/java/_Basics/Program to ReverseNumber (Java).java +++ /dev/null @@ -1,31 +0,0 @@ -/* - Reverse Number using Java - This Java Reverse Number Example shows how to reverse a given number. -*/ - -public class ReverseNumber -{ - - public static void main(String[] args) - { - //original number - int number = 1234; - int reversedNumber = 0; - int temp = 0; - while(number > 0) - { - //use modulus operator to strip off the last digit - temp = number%10; - //create the reversed number - reversedNumber = reversedNumber * 10 + temp; - number = number/10; - } - //output the reversed number - System.out.println("Reversed Number is: " + reversedNumber); - } -} - -/* -Output of this Number Reverse program would be -Reversed Number is: 4321 -*/ \ No newline at end of file diff --git a/java/_Basics/Program to Sort a Stack using a temporary Stack (Java).java b/java/_Basics/Program to Sort a Stack using a temporary Stack (Java).java deleted file mode 100644 index 809b0e1..0000000 --- a/java/_Basics/Program to Sort a Stack using a temporary Stack (Java).java +++ /dev/null @@ -1,42 +0,0 @@ -/* -You have a stack with full of integers. Sort it in the ascending order using another temporary array by using all stack functionality. -*/ - -import java.util.Stack; - -public class StackSort -{ - - public static Stack sortStack(Stack input) - { - Stack tmpStack = new Stack(); - System.out.println("=============== debug logs ================"); - while(!input.isEmpty()) - { - int tmp = input.pop(); - System.out.println("Element taken out: "+tmp); - while(!tmpStack.isEmpty() && tmpStack.peek() > tmp) - { - input.push(tmpStack.pop()); - } - tmpStack.push(tmp); - System.out.println("input: "+input); - System.out.println("tmpStack: "+tmpStack); - } - System.out.println("=============== debug logs ended ================"); - return tmpStack; - } - - public static void main(String a[]) - { - Stack input = new Stack(); - input.add(34); - input.add(3); - input.add(31); - input.add(98); - input.add(92); - input.add(23); - System.out.println("input: "+input); - System.out.println("final sorted list: "+sortStack(input)); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to Swap Elements (Java).java b/java/_Basics/Program to Swap Elements (Java).java deleted file mode 100644 index d0ff543..0000000 --- a/java/_Basics/Program to Swap Elements (Java).java +++ /dev/null @@ -1,40 +0,0 @@ -/* - Swap Numbers Java Example - This Swap Numbers Java Example shows how to - swap value of two numbers using java. -*/ - -public class SwapElementsExample -{ - - public static void main(String[] args) - { - int num1 = 10; - int num2 = 20; - System.out.println("Before Swapping"); - System.out.println("Value of num1 is :" + num1); - System.out.println("Value of num2 is :" +num2); - //swap the value - swap(num1, num2); - } - - private static void swap(int num1, int num2) - { - int temp = num1; - num1 = num2; - num2 = temp; - System.out.println("After Swapping"); - System.out.println("Value of num1 is :" + num1); - System.out.println("Value of num2 is :" +num2); - } -} - -/* -Output of Swap Numbers example would be -Before Swapping -Value of num1 is :10 -Value of num2 is :20 -After Swapping -Value of num1 is :20 -Value of num2 is :10 -*/ \ No newline at end of file diff --git a/java/_Basics/Program to Swap Elements Without Third Variable (Java).java b/java/_Basics/Program to Swap Elements Without Third Variable (Java).java deleted file mode 100644 index 65404df..0000000 --- a/java/_Basics/Program to Swap Elements Without Third Variable (Java).java +++ /dev/null @@ -1,37 +0,0 @@ -/* - Swap Numbers Without Using Third Variable Java Example - This Swap Numbers Java Example shows how to - swap value of two numbers without using third variable using java. -*/ - -public class SwapElementsWithoutThirdVariableExample -{ - - public static void main(String[] args) - { - int num1 = 10; - int num2 = 20; - System.out.println("Before Swapping"); - System.out.println("Value of num1 is :" + num1); - System.out.println("Value of num2 is :" +num2); - //add both the numbers and assign it to first - num1 = num1 + num2; - num2 = num1 - num2; - num1 = num1 - num2; - System.out.println("Before Swapping"); - System.out.println("Value of num1 is :" + num1); - System.out.println("Value of num2 is :" +num2); - } - - -} - -/* -Output of Swap Numbers Without Using Third Variable example would be -Before Swapping -Value of num1 is :10 -Value of num2 is :20 -Before Swapping -Value of num1 is :20 -Value of num2 is :10 -*/ \ No newline at end of file diff --git a/java/_Basics/Program to Write a singleton class (Java).java b/java/_Basics/Program to Write a singleton class (Java).java deleted file mode 100644 index 9a1600c..0000000 --- a/java/_Basics/Program to Write a singleton class (Java).java +++ /dev/null @@ -1,39 +0,0 @@ -/* -Singleton class means you can create only one object for the given class. -You can create a singleton class by making its constructor as private, -so that you can restrict the creation of the object. -Provide a static method to get instance of the object, wherein you can handle -the object creation inside the class only. In this example we are creating -object by using static block. -*/ - -public class MySingleton -{ - - private static MySingleton myObj; - - static - { - myObj = new MySingleton(); - } - - private MySingleton() - { - } - - public static MySingleton getInstance() - { - return myObj; - } - - public void testMe() - { - System.out.println("Hey.... it is working!!!"); - } - - public static void main(String a[]) - { - MySingleton ms = getInstance(); - ms.testMe(); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to check the given number is binary number or not (Java).java b/java/_Basics/Program to check the given number is binary number or not (Java).java deleted file mode 100644 index 669a2dc..0000000 --- a/java/_Basics/Program to check the given number is binary number or not (Java).java +++ /dev/null @@ -1,38 +0,0 @@ -/* -The binary numeral system, or base-2 number system, represents numeric values using two symbols: 0 and 1. More specifically, the usual base-2 system is a positional notation with a radix of 2. Because of its straightforward implementation in digital electronic circuitry using logic gates, the binary system is used internally by almost all modern computers. - -*/ - -public class MyBinaryCheck -{ - - public boolean isBinaryNumber(int binary) - { - boolean status = true; - while(true) - { - if(binary == 0) - { - break; - } - else - { - int tmp = binary%10; - if(tmp > 1) - { - status = false; - break; - } - binary = binary/10; - } - } - return status; - } - - public static void main(String a[]) - { - MyBinaryCheck mbc = new MyBinaryCheck(); - System.out.println("Is 1000111 binary? :"+mbc.isBinaryNumber(1000111)); - System.out.println("Is 10300111 binary? :"+mbc.isBinaryNumber(10300111)); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to check the input characcter for uppercas.java b/java/_Basics/Program to check the input characcter for uppercas.java deleted file mode 100644 index ae8eb57..0000000 --- a/java/_Basics/Program to check the input characcter for uppercas.java +++ /dev/null @@ -1,46 +0,0 @@ -Program to check the input characcter for uppercase, lowercase, no. of digits -and other characters - -import java.io.*; - -class InputDiagnosis{ - - public static void main(String args[]) throws IOException - { - char ch; - int digit=0; - int upper=0; - int lower=0; - int other=0; - - BufferedReader inputstream =new BufferedReader(new InputStreamReader(System.in)); - - System.out.println(" - - Type some text. When done, press Enter to Quit:"); - - - do{ - - ch=(char) inputstream.read(); - - if(Character.isDigit(ch)) - digit++; - else if(Character.isUpperCase(ch)) - upper++; - else if(Character.isLowerCase(ch)) - lower++; - else - other++; - - }while(ch !=' -'); - - - System.out.println("No Of Digits:" +digit); - System.out.println("No Of Uppercase Characters:" +upper); - System.out.println("No Of Lowercase Characters:" +lower); - System.out.println("No Of Other Characters:" +other); - - } - } diff --git a/java/_Basics/Program to convert binary to decimal number. (Java).java b/java/_Basics/Program to convert binary to decimal number. (Java).java deleted file mode 100644 index 66a6858..0000000 --- a/java/_Basics/Program to convert binary to decimal number. (Java).java +++ /dev/null @@ -1,36 +0,0 @@ -/* -Write a program to convert binary format to decimal number using numeric operations. Below example shows how to convert binary to decimal format using numeric operations. -*/ - -public class BinaryToDecimal -{ - - public int getDecimalFromBinary(int binary) - { - int decimal = 0; - int power = 0; - while(true) - { - if(binary == 0) - { - break; - } - else - { - int tmp = binary%10; - decimal += tmp*Math.pow(2, power); - binary = binary/10; - power++; - } - } - return decimal; - } - - public static void main(String a[]) - { - BinaryToDecimal bd = new BinaryToDecimal(); - System.out.println("11 ===> "+bd.getDecimalFromBinary(11)); - System.out.println("110 ===> "+bd.getDecimalFromBinary(110)); - System.out.println("100110 ===> "+bd.getDecimalFromBinary(100110)); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to convert decimal number to binary format. (Java).java b/java/_Basics/Program to convert decimal number to binary format. (Java).java deleted file mode 100644 index 8ea92a1..0000000 --- a/java/_Basics/Program to convert decimal number to binary format. (Java).java +++ /dev/null @@ -1,28 +0,0 @@ -/* -Write a program to convert decimal number to binary format using numeric operations. Below example shows how to convert decimal number to binary format using numeric operations. -*/ - -public class DecimalToBinary -{ - - public void printBinaryFormat(int number) - { - int binary[] = new int[25]; - int index = 0; - while(number > 0) - { - binary[index++] = number%2; - number = number/2; - } - for(int i = index-1; i >= 0; i--) - { - System.out.print(binary[i]); - } - } - - public static void main(String a[]) - { - DecimalToBinary dtb = new DecimalToBinary(); - dtb.printBinaryFormat(25); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to convert string to number without using Integer.parseInt() method (Java).java b/java/_Basics/Program to convert string to number without using Integer.parseInt() method (Java).java deleted file mode 100644 index dca2a6a..0000000 --- a/java/_Basics/Program to convert string to number without using Integer.parseInt() method (Java).java +++ /dev/null @@ -1,28 +0,0 @@ -/* -Below example shows how to convert string format of a number to number without calling Integer.parseInt() method. We can do this by converting each character into ascii format and form the number. -*/ - -public class MyStringToNumber -{ - - public static int convert_String_To_Number(String numStr) - { - char ch[] = numStr.toCharArray(); - int sum = 0; - //get ascii value for zero - int zeroAscii = (int)'0'; - for(char c:ch) - { - int tmpAscii = (int)c; - sum = (sum*10)+(tmpAscii-zeroAscii); - } - return sum; - } - - public static void main(String a[]) - { - System.out.println("\"3256\" == "+convert_String_To_Number("3256")); - System.out.println("\"76289\" == "+convert_String_To_Number("76289")); - System.out.println("\"90087\" == "+convert_String_To_Number("90087")); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to create GUI for Bank Account Simulation.java b/java/_Basics/Program to create GUI for Bank Account Simulation.java deleted file mode 100644 index c78e6fc..0000000 --- a/java/_Basics/Program to create GUI for Bank Account Simulation.java +++ /dev/null @@ -1,135 +0,0 @@ -// Program to create GUI for Bank Account Simulation - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -class GuiAccTest extends Frame implements ActionListener -{ - Label lab=new Label(" "); - Label lab1=new Label(" "); - TextField t[]=new TextField [4]; - Label l[]=new Label [4]; - Button but=new Button("Create Account"); - Button but1=new Button("Test Account"); - BankAccount b; - GuiAccTest() - { - addWindowListener(new NewWindowAdapter()); - setLayout(new GridLayout(2,0)); - Panel p=new Panel(); - Panel p1=new Panel(); - but.addActionListener(this); - but1.addActionListener(this); - p.setLayout(new GridLayout(5,2)); - p1.add(lab1); - p1.add(lab); - l[0]=new Label("Account Number"); - l[1]=new Label("Initial Balance"); - l[2]=new Label("Deposit Amount"); - l[3]=new Label("Withdraw Amount"); - for(int i=0;i<4;i++) - { - t[i]=new TextField(10); - p.add(l[i]); - p.add(t[i]); - } - p.add(but); - p.add(but1); - but1.setVisible(false); - l[2].setVisible(false); - l[3].setVisible(false); - t[2].setVisible(false); - t[3].setVisible(false); - add(p); - add(p1); - } - String testAccount(int d_amt,int w_amt) - { - String msg; - b.deposit(d_amt); - msg="Transaction Succesful"; - try - { - b.withdraw(w_amt); - }catch(FundsInsufficientException fe) - { - fe=new FundsInsufficientException(b.amount,w_amt); - msg=String.valueOf(fe); - } - return msg; - } - public void actionPerformed(ActionEvent ae) - { - String str=ae.getActionCommand(); - if(str.equals("Create Account")) - { - b=new BankAccount(Integer.parseInt(t[0].getText()),Integer.parseInt(t[1].getText())); - but1.setVisible(true); - l[2].setVisible(true); - l[3].setVisible(true); - t[2].setVisible(true); - t[3].setVisible(true); - but.setVisible(false); - l[0].setVisible(false); - l[1].setVisible(false); - t[0].setVisible(false); - t[1].setVisible(false); - lab1.setText("Account : "+b.accnum+", Current Balance : "+b.amount); - return; - } - else - { - lab.setText(testAccount(Integer.parseInt(t[2].getText()),Integer.parseInt(t[3].getText()))); - lab1.setText("Account : "+b.accnum+", Current Balance : "+b.amount); - } - } - public static void main(String arg[]) - { - GuiAccTest at=new GuiAccTest(); - at.setTitle("Bank Account Tester"); - at.setSize(600,200); - at.setVisible(true); - } -} -class NewWindowAdapter extends WindowAdapter -{ - public void windowClosing(WindowEvent we) - { - System.exit(0); - } -} -class BankAccount -{ - int accnum; - int amount; - BankAccount(int num,int amt) - { - accnum=num; - amount=amt; - } - public void deposit(int amt) - { - amount=amount+amt; - } - public void withdraw(int amt) throws FundsInsufficientException - { - if(amt>amount) - throw new FundsInsufficientException(amount,amt); - else - amount=amount-amt; - } -} -class FundsInsufficientException extends Exception -{ - int balance; - int withdraw_amount; - FundsInsufficientException(int bal,int w_amt) - { - balance=bal; - withdraw_amount=w_amt; - } - public String toString() - { - return "Your withdraw amount ("+withdraw_amount+") is less than the balance ("+balance+"). No withdrawal was recorded."; - } -} diff --git a/java/_Basics/Program to create deadlock between two threads. (Java).java b/java/_Basics/Program to create deadlock between two threads. (Java).java deleted file mode 100644 index 2b67466..0000000 --- a/java/_Basics/Program to create deadlock between two threads. (Java).java +++ /dev/null @@ -1,57 +0,0 @@ -/* -Deadlock describes a situation where two or more threads are blocked forever, - waiting for each other. Deadlocks can occur in Java when the synchronized - keyword causes the executing thread to block while waiting to get the lock, - associated with the specified object. Since the thread might already hold - locks associated with other objects, two threads could each be waiting for - the other to release a lock. -In such case, they will end up waiting forever. -*/ - -public class MyDeadlock -{ - - String str1 = "Java"; - String str2 = "UNIX"; - - Thread trd1 = new Thread("My Thread 1") - { - public void run() - { - while(true) - { - synchronized(str1) - { - synchronized(str2) - { - System.out.println(str1 + str2); - } - } - } - } - }; - - Thread trd2 = new Thread("My Thread 2") - { - public void run() - { - while(true) - { - synchronized(str2) - { - synchronized(str1) - { - System.out.println(str2 + str1); - } - } - } - } - }; - - public static void main(String a[]) - { - MyDeadlock mdl = new MyDeadlock(); - mdl.trd1.start(); - mdl.trd2.start(); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to determine if a number is Prime (Java).java b/java/_Basics/Program to determine if a number is Prime (Java).java deleted file mode 100644 index 0c68f42..0000000 --- a/java/_Basics/Program to determine if a number is Prime (Java).java +++ /dev/null @@ -1,20 +0,0 @@ -class PrimeExample -{ - public static void main(String args[]) - { - int i,m=0,flag=0; - int n=17;//it is the number to be checked - m=n/2; - for(i=2; i<=m; i++) - { - if(n%i==0) - { - System.out.println("Number is not prime"); - flag=1; - break; - } - } - if(flag==0) - System.out.println("Number is prime"); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to find all distinct words from the given file. Remove special chars. (Java).java b/java/_Basics/Program to find all distinct words from the given file. Remove special chars. (Java).java deleted file mode 100644 index b49528a..0000000 --- a/java/_Basics/Program to find all distinct words from the given file. Remove special chars. (Java).java +++ /dev/null @@ -1,71 +0,0 @@ -/* -Write a program to find all distinct words from the given file. Remove special chars like ".,;:" etc. Ignore case sensitivity. -*/ - -import java.io.BufferedReader; -import java.io.DataInputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -public class MyDistinctFileWords -{ - - public List getDistinctWordList(String fileName) - { - FileInputStream fis = null; - DataInputStream dis = null; - BufferedReader br = null; - List wordList = new ArrayList(); - try - { - fis = new FileInputStream(fileName); - dis = new DataInputStream(fis); - br = new BufferedReader(new InputStreamReader(dis)); - String line = null; - while((line = br.readLine()) != null) - { - StringTokenizer st = new StringTokenizer(line, " ,.;:\""); - while(st.hasMoreTokens()) - { - String tmp = st.nextToken().toLowerCase(); - if(!wordList.contains(tmp)) - { - wordList.add(tmp); - } - } - } - } - catch (FileNotFoundException e) - { - e.printStackTrace(); - } - catch (IOException e) - { - e.printStackTrace(); - } - finally - { - try - { - if(br != null) br.close(); - } - catch(Exception ex) {} - } - return wordList; - } - - public static void main(String a[]) - { - MyDistinctFileWords distFw = new MyDistinctFileWords(); - List wordList = distFw.getDistinctWordList("C:/sample.txt"); - for(String str:wordList) - { - System.out.println(str); - } - } -} \ No newline at end of file diff --git a/java/_Basics/Program to find common elements between two arrays. (Java).java b/java/_Basics/Program to find common elements between two arrays. (Java).java deleted file mode 100644 index 6345716..0000000 --- a/java/_Basics/Program to find common elements between two arrays. (Java).java +++ /dev/null @@ -1,26 +0,0 @@ -/* -Write a program to identify common elements or numbers between -two given arrays. You should not use any inbuilt methods are list to -find common values. -*/ - - -public class CommonElementsInArray -{ - - public static void main(String a[]) - { - int[] arr1 = {4,7,3,9,2}; - int[] arr2 = {3,2,12,9,40,32,4}; - for(int i=0; i getWordCount(String fileName) - { - FileInputStream fis = null; - DataInputStream dis = null; - BufferedReader br = null; - Map wordMap = new HashMap(); - try - { - fis = new FileInputStream(fileName); - dis = new DataInputStream(fis); - br = new BufferedReader(new InputStreamReader(dis)); - String line = null; - while((line = br.readLine()) != null) - { - StringTokenizer st = new StringTokenizer(line, " "); - while(st.hasMoreTokens()) - { - String tmp = st.nextToken().toLowerCase(); - if(wordMap.containsKey(tmp)) - { - wordMap.put(tmp, wordMap.get(tmp)+1); - } - else - { - wordMap.put(tmp, 1); - } - } - } - } - catch (FileNotFoundException e) - { - e.printStackTrace(); - } - catch (IOException e) - { - e.printStackTrace(); - } - finally - { - try - { - if(br != null) br.close(); - } - catch(Exception ex) {} - } - return wordMap; - } - - public List> sortByValue(Map wordMap) - { - Set> set = wordMap.entrySet(); - List> list = new ArrayList>(set); - Collections.sort( list, new Comparator>() - { - public int compare( Map.Entry o1, Map.Entry o2 ) - { - return (o2.getValue()).compareTo( o1.getValue() ); - } - } ); - return list; - } - - public static void main(String a[]) - { - MaxDuplicateWordCount mdc = new MaxDuplicateWordCount(); - Map wordMap = mdc.getWordCount("C:/MyTestFile.txt"); - List> list = mdc.sortByValue(wordMap); - for(Map.Entry entry:list) - { - System.out.println(entry.getKey()+" ==== "+entry.getValue()); - } - } -} diff --git a/java/_Basics/Program to find missing numbers in an array (Java).java b/java/_Basics/Program to find missing numbers in an array (Java).java deleted file mode 100644 index 081aa2c..0000000 --- a/java/_Basics/Program to find missing numbers in an array (Java).java +++ /dev/null @@ -1,53 +0,0 @@ -/* -To find missing numbers in an array first we need to make sure that array is sorted. -After sorting we need to check that array each element with next element then we can find the difference. -if Array is not sorted :To sort array use Arrays.sort(array); -If difference is 1 then no need to do any thing because numbers are in order. -If difference is not equal to 1 then we need to print all those numbers or pick those numbers and place it in one array. -this would be the logic to find missing numbers in an array -Here there may be a chance of array not starts with 1 then we need to check first itself whether array starts with 1 or not if not we need to print 1 to starting element of array. -for example int a[]={4,5,6,8}; then we need to print 1 2 3 7. -*/ - -public class PrintMissingNumbers -{ - - private static void findMissingNumber(int[] number) - { - // take max length as last number in array - int k[] = new int[number[number.length-1]]; - int m=0; - if(number[0]!=1) - { - for (int x = 1; x < number[0]; x++) - { - k[m] = x; - m++; - } - } - for (int i = 0; i < number.length -1; i++) - { - int j = i+1; - int difference = number[j] - number[i] ; - if(difference != 1 ) - { - for (int x = 1; x < difference; x++) - { - k[m] = number[i] + x; - m++; - } - } - } - System.out.println("missing numbers in array ::"); - for (int l = 0; l < m ; l++) - { - System.out.println( k[l]+" "); - } - } - public static void main(String[] args) - { - int a[]= {2,4,6,9,10,20}; - //if Array is not sorted :To sort array use ArraysC.sort(a); - findMissingNumber(a); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to find out duplicate characters in a string. (Java).java b/java/_Basics/Program to find out duplicate characters in a string. (Java).java deleted file mode 100644 index 25295f2..0000000 --- a/java/_Basics/Program to find out duplicate characters in a string. (Java).java +++ /dev/null @@ -1,43 +0,0 @@ -/* -Write a program to find out duplicate or repeated characters in a -string, and calculate the count of repeatation. -*/ - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -public class DuplicateCharsInString -{ - - public void findDuplicateChars(String str) - { - Map dupMap = new HashMap(); - char[] chrs = str.toCharArray(); - for(Character ch:chrs) - { - if(dupMap.containsKey(ch)) - { - dupMap.put(ch, dupMap.get(ch)+1); - } - else - { - dupMap.put(ch, 1); - } - } - Set keys = dupMap.keySet(); - for(Character ch:keys) - { - if(dupMap.get(ch) > 1) - { - System.out.println(ch+"--->"+dupMap.get(ch)); - } - } - } - - public static void main(String a[]) - { - DuplicateCharsInString dcs = new DuplicateCharsInString(); - dcs.findDuplicateChars("Java2Novice"); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to find perfect number or not. (Java).java b/java/_Basics/Program to find perfect number or not. (Java).java deleted file mode 100644 index a6ef3d9..0000000 --- a/java/_Basics/Program to find perfect number or not. (Java).java +++ /dev/null @@ -1,42 +0,0 @@ -/* -A perfect number is a positive integer that is equal to the sum -of its proper positive divisors, that is, the sum of its positive -divisors excluding the number itself. Equivalently, a perfect number -is a number that is half the sum of all of its positive divisors. -The first perfect number is 6, because 1, 2 and 3 are its proper -positive divisors, and 1 + 2 + 3 = 6. Equivalently, the number 6 -is equal to half the sum of all its positive divisors: - ( 1 + 2 + 3 + 6 ) / 2 = 6. -*/ - -public class IsPerfectNumber -{ - - public boolean isPerfectNumber(int number) - { - int temp = 0; - for(int i=1; i<=number/2; i++) - { - if(number%i == 0) - { - temp += i; - } - } - if(temp == number) - { - System.out.println("It is a perfect number"); - return true; - } - else - { - System.out.println("It is not a perfect number"); - return false; - } - } - - public static void main(String a[]) - { - IsPerfectNumber ipn = new IsPerfectNumber(); - System.out.println("Is perfect number: "+ipn.isPerfectNumber(28)); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to find sum of each digit in the given number using recursion. (Java).java b/java/_Basics/Program to find sum of each digit in the given number using recursion. (Java).java deleted file mode 100644 index e28d023..0000000 --- a/java/_Basics/Program to find sum of each digit in the given number using recursion. (Java).java +++ /dev/null @@ -1,30 +0,0 @@ -/* -Below example shows how to find out sum of each digit in the given number using recursion logic. For example, if the number is 259, then the sum should be 2+5+9 = 16. -*/ - - -public class MyNumberSumRec -{ - - int sum = 0; - - public int getNumberSum(int number) - { - if(number == 0) - { - return sum; - } - else - { - sum += (number%10); - getNumberSum(number/10); - } - return sum; - } - - public static void main(String a[]) - { - MyNumberSumRec mns = new MyNumberSumRec(); - System.out.println("Sum is: "+mns.getNumberSum(223)); - } -} \ No newline at end of file diff --git a/java/_Basics/Program to find the sum of the first 1000 prime numbers (Java).java b/java/_Basics/Program to find the sum of the first 1000 prime numbers (Java).java deleted file mode 100644 index cb41af7..0000000 --- a/java/_Basics/Program to find the sum of the first 1000 prime numbers (Java).java +++ /dev/null @@ -1,35 +0,0 @@ -/* -Program to find the sum of the first 1000 prime numbers. -*/ -public class Main -{ - - public static void main(String args[]) - { - int number = 2; - int count = 0; - long sum = 0; - while(count < 1000) - { - if(isPrimeNumber(number)) - { - sum += number; - count++; - } - number++; - } - System.out.println(sum); - } - - private static boolean isPrimeNumber(int number) - { - for(int i=2; i<=number/2; i++) - { - if(number % i == 0) - { - return false; - } - } - return true; - } -} \ No newline at end of file diff --git a/java/_Basics/Program to find top two maximum numbers in a array. (Java).java b/java/_Basics/Program to find top two maximum numbers in a array. (Java).java deleted file mode 100644 index 7b47100..0000000 --- a/java/_Basics/Program to find top two maximum numbers in a array. (Java).java +++ /dev/null @@ -1,42 +0,0 @@ -/* -Write a program to find top two maximum numbers in the -given array. You should not use any sorting functions. You -should iterate the array only once. You should not use any -kind of collections in java. -*/ - -public class TwoMaxNumbers -{ - - public void printTwoMaxNumbers(int[] nums) - { - int maxOne = 0; - int maxTwo = 0; - for(int n:nums) - { - if(maxOne < n) - { - maxTwo = maxOne; - maxOne =n; - } - else if(maxTwo < n) - { - maxTwo = n; - } - } - System.out.println("First Max Number: "+maxOne); - System.out.println("Second Max Number: "+maxTwo); - } - - public static void main(String a[]) - { - int num[] = {5,34,78,2,45,1,99,23}; - TwoMaxNumbers tmn = new TwoMaxNumbers(); - tmn.printTwoMaxNumbers(num); - } -} - -/* -Output: -First Max Number: 99 -Second Max Number: 78 \ No newline at end of file diff --git a/java/_Basics/Program to find two lines with max characters in descending order (Java).java b/java/_Basics/Program to find two lines with max characters in descending order (Java).java deleted file mode 100644 index b45bc50..0000000 --- a/java/_Basics/Program to find two lines with max characters in descending order (Java).java +++ /dev/null @@ -1,85 +0,0 @@ -/* -Write a program to read a multiple line text file and write the 'N' longest lines to the output console, where the file to be read is specified as command line aruguments. The program should read an input file. The first line should contain the value of the number 'N' followed by multiple lines. 'N' should be a valid positive integer. -*/ -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Comparator; -import java.util.Set; -import java.util.TreeSet; - -public class Main -{ - - public static void main(String[] args) - { - BufferedReader br = null; - String filePath = args[0]; - int topList = 0; - Set liSet = new TreeSet(new MyComp()); - try - { - br = new BufferedReader(new FileReader(new File(filePath))); - String line = br.readLine(); - topList = Integer.parseInt(line.trim()); - while((line = br.readLine()) != null) - { - line = line.trim(); - if(!"".equals(line)) - { - liSet.add(new Entries(line.length(), line)); - } - } - int count = 0; - for(Entries ent:liSet) - { - System.out.println(ent.line); - if(++count == topList) - { - break; - } - } - } - catch (FileNotFoundException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - catch (IOException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public static class Entries - { - Integer length; - String line; - public Entries(Integer l,String line) - { - length = l; - this.line = line; - } - } - - public static class MyComp implements Comparator - { - - @Override - public int compare(Entries e1, Entries e2) - { - if(e2.length > e1.length) - { - return 1; - } - else - { - return -1; - } - } - - } -} \ No newline at end of file diff --git a/java/_Basics/Program to get a line with max word count from the given file. (Java).java b/java/_Basics/Program to get a line with max word count from the given file. (Java).java deleted file mode 100644 index fdb4035..0000000 --- a/java/_Basics/Program to get a line with max word count from the given file. (Java).java +++ /dev/null @@ -1,97 +0,0 @@ -/* -Below example shows how to find out the line with maximum number of word count in the given file. In case if it has multiple lines with max number of words, then it has to list all those lines. -*/ - - -import java.io.BufferedReader; -import java.io.DataInputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; - -public class MaxWordCountInLine -{ - - private int currentMaxCount = 0; - private List lines = new ArrayList(); - - public void readMaxLineCount(String fileName) - { - FileInputStream fis = null; - DataInputStream dis = null; - BufferedReader br = null; - try - { - fis = new FileInputStream(fileName); - dis = new DataInputStream(fis); - br = new BufferedReader(new InputStreamReader(dis)); - String line = null; - while((line = br.readLine()) != null) - { - int count = (line.split("\\s+")).length; - if(count > currentMaxCount) - { - lines.clear(); - lines.add(line); - currentMaxCount = count; - } - else if(count == currentMaxCount) - { - lines.add(line); - } - } - } - catch (FileNotFoundException e) - { - e.printStackTrace(); - } - catch (IOException e) - { - e.printStackTrace(); - } - finally - { - try - { - if(br != null) br.close(); - } - catch(Exception ex) {} - } - } - - public int getCurrentMaxCount() - { - return currentMaxCount; - } - - public void setCurrentMaxCount(int currentMaxCount) - { - this.currentMaxCount = currentMaxCount; - } - - public List getLines() - { - return lines; - } - - public void setLines(List lines) - { - this.lines = lines; - } - - public static void main(String a[]) - { - MaxWordCountInLine mdc = new MaxWordCountInLine(); - mdc.readMaxLineCount("/Users/ngootooru/MyTestFile.txt"); - System.out.println("Max number of words in a line is: "+mdc.getCurrentMaxCount()); - System.out.println("Line with max word count:"); - List lines = mdc.getLines(); - for(String l:lines) - { - System.out.println(l); - } - } -} \ No newline at end of file diff --git a/java/_Basics/Program to get distinct word list from the given file. (Java).java b/java/_Basics/Program to get distinct word list from the given file. (Java).java deleted file mode 100644 index b49528a..0000000 --- a/java/_Basics/Program to get distinct word list from the given file. (Java).java +++ /dev/null @@ -1,71 +0,0 @@ -/* -Write a program to find all distinct words from the given file. Remove special chars like ".,;:" etc. Ignore case sensitivity. -*/ - -import java.io.BufferedReader; -import java.io.DataInputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -public class MyDistinctFileWords -{ - - public List getDistinctWordList(String fileName) - { - FileInputStream fis = null; - DataInputStream dis = null; - BufferedReader br = null; - List wordList = new ArrayList(); - try - { - fis = new FileInputStream(fileName); - dis = new DataInputStream(fis); - br = new BufferedReader(new InputStreamReader(dis)); - String line = null; - while((line = br.readLine()) != null) - { - StringTokenizer st = new StringTokenizer(line, " ,.;:\""); - while(st.hasMoreTokens()) - { - String tmp = st.nextToken().toLowerCase(); - if(!wordList.contains(tmp)) - { - wordList.add(tmp); - } - } - } - } - catch (FileNotFoundException e) - { - e.printStackTrace(); - } - catch (IOException e) - { - e.printStackTrace(); - } - finally - { - try - { - if(br != null) br.close(); - } - catch(Exception ex) {} - } - return wordList; - } - - public static void main(String a[]) - { - MyDistinctFileWords distFw = new MyDistinctFileWords(); - List wordList = distFw.getDistinctWordList("C:/sample.txt"); - for(String str:wordList) - { - System.out.println(str); - } - } -} \ No newline at end of file diff --git a/java/_Basics/Program to implement ArrayList (Java).java b/java/_Basics/Program to implement ArrayList (Java).java deleted file mode 100644 index 2abc6fb..0000000 --- a/java/_Basics/Program to implement ArrayList (Java).java +++ /dev/null @@ -1,105 +0,0 @@ -/* -Write a program to implement your own ArrayList class. It should -contain add(), get(), remove(), size() methods. Use dynamic array logic. -It should increase its size when it reaches threshold. -*/ - - -import java.util.Arrays; - -public class MyArrayList -{ - - private Object[] myStore; - private int actSize = 0; - - public MyArrayList() - { - myStore = new Object[10]; - } - - public Object get(int index) - { - if(index < actSize) - { - return myStore[index]; - } - else - { - throw new ArrayIndexOutOfBoundsException(); - } - } - - public void add(Object obj) - { - if(myStore.length-actSize <= 5) - { - increaseListSize(); - } - myStore[actSize++] = obj; - } - - public Object remove(int index) - { - if(index < actSize) - { - Object obj = myStore[index]; - myStore[index] = null; - int tmp = index; - while(tmp < actSize) - { - myStore[tmp] = myStore[tmp+1]; - myStore[tmp+1] = null; - tmp++; - } - actSize--; - return obj; - } - else - { - throw new ArrayIndexOutOfBoundsException(); - } - } - - public int size() - { - return actSize; - } - - private void increaseListSize() - { - myStore = Arrays.copyOf(myStore, myStore.length*2); - System.out.println("\nNew length: "+myStore.length); - } - - public static void main(String a[]) - { - MyArrayList mal = new MyArrayList(); - mal.add(new Integer(2)); - mal.add(new Integer(5)); - mal.add(new Integer(1)); - mal.add(new Integer(23)); - mal.add(new Integer(14)); - for(int i=0; i hm = new HashMap(); - hm.put(new Price("Banana", 20), "Banana"); - hm.put(new Price("Apple", 40), "Apple"); - hm.put(new Price("Orange", 30), "Orange"); - //creating new object to use as key to get value - Price key = new Price("Banana", 20); - System.out.println("Hashcode of the key: "+key.hashCode()); - System.out.println("Value from map: "+hm.get(key)); - } -} - -class Price -{ - - private String item; - private int price; - - public Price(String itm, int pr) - { - this.item = itm; - this.price = pr; - } - - public int hashCode() - { - System.out.println("In hashcode"); - int hashcode = 0; - hashcode = price*20; - hashcode += item.hashCode(); - return hashcode; - } - - public boolean equals(Object obj) - { - System.out.println("In equals"); - if (obj instanceof Price) - { - Price pp = (Price) obj; - return (pp.item.equals(this.item) && pp.price == this.price); - } - else - { - return false; - } - } - - public String getItem() - { - return item; - } - public void setItem(String item) - { - this.item = item; - } - public int getPrice() - { - return price; - } - public void setPrice(int price) - { - this.price = price; - } - - public String toString() - { - return "item: "+item+" price: "+price; - } -} \ No newline at end of file diff --git a/java/_Basics/Program to remove duplicates from sorted array. (Java).java b/java/_Basics/Program to remove duplicates from sorted array. (Java).java deleted file mode 100644 index 13e0f94..0000000 --- a/java/_Basics/Program to remove duplicates from sorted array. (Java).java +++ /dev/null @@ -1,45 +0,0 @@ -/* -Given array is already sorted, and it has duplicate elements. Write a program to remove duplicate elements and return new array without any duplicate elements. The array should contain only unique elements. -*/ - -public class MyDuplicateElements -{ - - public static int[] removeDuplicates(int[] input) - { - int j = 0; - int i = 1; - //return if the array length is less than 2 - if(input.length < 2) - { - return input; - } - while(i < input.length) - { - if(input[i] == input[j]) - { - i++; - } - else - { - input[++j] = input[i++]; - } - } - int[] output = new int[j+1]; - for(int k=0; k map = new HashMap(); - map.put("java", 20); - map.put("C++", 45); - map.put("Java2Novice", 2); - map.put("Unix", 67); - map.put("MAC", 26); - map.put("Why this kolavari", 93); - Set> set = map.entrySet(); - List> list = new ArrayList>(set); - Collections.sort( list, new Comparator>() - { - public int compare( Map.Entry o1, Map.Entry o2 ) - { - return (o2.getValue()).compareTo( o1.getValue() ); - } - } ); - for(Map.Entry entry:list) - { - System.out.println(entry.getKey()+" ==== "+entry.getValue()); - } - } -} diff --git a/java/_Basics/Raise Exceptions.java b/java/_Basics/Raise Exceptions.java deleted file mode 100644 index d5469d7..0000000 --- a/java/_Basics/Raise Exceptions.java +++ /dev/null @@ -1,42 +0,0 @@ -Raise Exceptions - - - - - -/** - * This example demonstrates how to catch - * multiple exceptions that are raised in - * a try block - */ -public class RaiseExceptions { - public static void main( String[] args ) { - try { - Integer.parseInt( "a" ); - double[] amounts = new double[-10]; - "hello".charAt( -1 ); - String str = args[6]; - ( (String) null ).length(); - int a = 3 / 0; - } - catch( NumberFormatException nfex ) { - System.out.println( nfex ); - } - catch( NegativeArraySizeException nasex ) { - System.out.println( nasex ); - } - catch( StringIndexOutOfBoundsException siex ) { - System.out.println( siex ); - } - catch( ArrayIndexOutOfBoundsException arex ) { - System.out.println( arex ); - } - catch( NullPointerException npex ) { - System.out.println( npex ); - } - catch( ArithmeticException aex ) { - System.out.println( aex ); - } - - } -} diff --git a/java/_Basics/Rotation.java b/java/_Basics/Rotation.java deleted file mode 100644 index c92ebb0..0000000 --- a/java/_Basics/Rotation.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.jwetherell.algorithms.strings; - -/** - * Rotation of the string is some cyclic transformation of that string. - * More formally a string s = uv is said to be a rotation of t if t = vu. - *

- * http://en.wikipedia.org/wiki/String_(computer_science)#Rotations - *
- * @Author Szymon Stankiewicz - * @author Justin Wetherell - */ -public class Rotation { - - private static char charAt(String text, int pos) { - pos = pos % text.length(); - return text.charAt(pos); - } - - private static int compare(char a, char b, boolean greater) { - if (a == b) - return 0; - return (a < b) ^ greater ? -1 : 1; - } - - private static String bestRotation(String text, boolean greatest) { - if (text.length() < 2) - return text; - - final int n = text.length() * 2; - int k = 0; - int i = 0, j = 1; - while (i + k < n && j + k < n) { - final char a = charAt(text, i+k); - final char b = charAt(text, j+k); - final int comp = compare(a, b, greatest); - if (comp == 0) { - k++; - } else if (comp > 0) { - i += k+1; - if (i <= j ) - i = j + 1; - k = 0; - } else { - j += k+1; - if (j <= i) - j = i + 1; - k = 0; - } - } - final int pos = i < j ? i : j; - return text.substring(pos) + text.substring(0, pos); - } - - /** - * Finds lexicographically minimal string rotation. - * Lexicographically minimal string rotation is a rotation of a string possessing the - * lowest lexicographical order of all such rotations. - * Finding the lexicographically minimal rotation is useful as a way of normalizing strings. - *

- * http://en.wikipedia.org/wiki/Lexicographically_minimal_string_rotation - *
- * This function implements Duval's algorithm. - *
- * http://en.wikipedia.org/wiki/Lexicographically_minimal_string_rotation#Duval.27s_Lyndon_Factorization_Algorithm - * Complexity: O(n) - *
- * @param text - * @return lexicographicall minimal rotation of text - */ - public static String getLexicographicallyMinimalRotation(String text) { - return bestRotation(text, false); - } - - /** - * Finds lexicographically maximal string rotation. - * Lexicographically maximal string rotation is a rotation of a string possessing the - * highest lexicographical order of all such rotations. - * Finding the lexicographically maximal rotation is useful as a way of normalizing strings. - *

- * http://en.wikipedia.org/wiki/Lexicographically_minimal_string_rotation - *
- * This function implements Duval's algorithm. - * http://en.wikipedia.org/wiki/Lexicographically_minimal_string_rotation#Duval.27s_Lyndon_Factorization_Algorithm - *
- * Complexity: O(n) - *
- * @param text - * @return lexicographicall minimal rotation of text - */ - public static String getLexicographicallyMaximalRotation(String text) { - return bestRotation(text, true); - } -} diff --git a/java/_Basics/School Management System.java b/java/_Basics/School Management System.java deleted file mode 100644 index 590a8eb..0000000 --- a/java/_Basics/School Management System.java +++ /dev/null @@ -1,405 +0,0 @@ -School Management System - -import java.awt.*; -import java.io.*; -import java.util.*; -import javax.swing.*; -import javax.swing.event.*; -import java.awt.event.*; - -public class ProjectX extends JFrame implements ChangeListener, -ActionListener -{ - static int choice = 0; - static String line = "-------------------------------- -"; - DataInputStream inputData = new DataInputStream(System.in); - private Registration studentDetails = new Registration(); - int topScore = studentDetails.getTopScore(); - int passMarks = studentDetails.getPassMarks(); - int firstClass = studentDetails.getFirstClass(); - int secondClass = studentDetails.getSecondClass(); - - JTabbedPane tabbedPane = new JTabbedPane(); - JLabel statusLabel = new JLabel(); - JLabel titleLabel = new JLabel("Student Software Beta Edition"); - JPanel addStudentPanel = new JPanel(); - JTextField studentName = new JTextField(); - JTextField physicsMarks = new JTextField(); - JTextField biologyMarks = new JTextField(); - JTextField mathsMarks = new JTextField(); - JButton submitDetails = new JButton("Submit Details"); - JPanel studentDetailsPanel = new JPanel(); - JTextField studentID1 = new JTextField(); - JTextArea studentInfo = new JTextArea(); - JButton submitID1 = new JButton("Submit ID"); - JPanel studentGradePanel = new JPanel(); - JTextField studentID2 = new JTextField(); - JTextArea studentGrade = new JTextArea(); - JButton submitID2 = new JButton("Submit ID"); - JPanel numberPassedPanel = new JPanel(); - JTextArea studentPassed = new JTextArea(); - JPanel classTopperPanel = new JPanel(); - JTextArea studentTopper = new JTextArea(); - - public ProjectX(String frameTitle) - { - super(frameTitle); - setResizable(true); - setSize(400,400); - submitDetails.addActionListener(this); - submitID1.addActionListener(this); - submitID2.addActionListener(this); - - getContentPane().setLayout(new BorderLayout()); - - getContentPane().add(titleLabel,"North"); - - tabbedPane.addTab("Add Student",addStudentPanel); - addStudentPanel.setLayout(new GridLayout(8,2,5,5)); - addStudentPanel.add(new JLabel("Student Name: ")); - addStudentPanel.add(studentName); - addStudentPanel.add(new JLabel("Physics Marks: ")); - addStudentPanel.add(physicsMarks); - addStudentPanel.add(new JLabel("Biology Marks: ")); - addStudentPanel.add(biologyMarks); - addStudentPanel.add(new JLabel("Maths Marks: ")); - addStudentPanel.add(mathsMarks); - addStudentPanel.add(submitDetails); - - tabbedPane.addTab("Student Details",studentDetailsPanel); - studentDetailsPanel.add(new JLabel("Enter Student ID: ")); - studentDetailsPanel.add(studentID1); - studentDetailsPanel.add(submitID1); - studentDetailsPanel.add(new JLabel("Student Details:")); - studentDetailsPanel.add(studentInfo); - - tabbedPane.addTab("Student Grade",studentGradePanel); - studentGradePanel.setLayout(new GridLayout(5,2,5,5)); - studentGradePanel.add(new JLabel("Enter Student ID: ")); - studentGradePanel.add(studentID2); - studentGradePanel.add(submitID2); - studentGradePanel.add(new JLabel("Student Grade:")); - studentGradePanel.add(studentGrade); - - tabbedPane.addTab("Passed Student",numberPassedPanel); - numberPassedPanel.setLayout(new GridLayout(2,2,5,5)); - numberPassedPanel.add(new JLabel("Number of Student Passed: ")); - numberPassedPanel.add(studentPassed); - - tabbedPane.addTab("Class Topper",classTopperPanel); - classTopperPanel.setLayout(new GridLayout(2,2,5,5)); - classTopperPanel.add(new JLabel("Here are the class Toppers: ")); - classTopperPanel.add(studentTopper); - - tabbedPane.addChangeListener(this); - getContentPane().add(tabbedPane,"Center"); - - statusLabel.setText("Status: Normal"); - getContentPane().add(statusLabel,"South"); - - setVisible(true); - - } - - public static void main(String args[]) - { - ProjectX outputScreen = new ProjectX("Case Study"); - } - - public String setStudentInfo() - { - int id = studentDetails.addStudent(studentName.getText(), -Integer.parseInt(physicsMarks.getText()), -Integer.parseInt(biologyMarks.getText()), -Integer.parseInt(mathsMarks.getText())); - return (" -" + - line + - "Record Created For " + studentName + - " -" + - "Student ID: " + id + - " -" + - line ); - } - - public String getStudentInfo() - { - int id = Integer.parseInt(studentID1.getText()); - if(studentDetails.getStudentDetails(id)) - return (" -" + - line + - "Student Details -" + - line + - "Student ID:" + " " + id + " -" + - "Student Name:" + " " + studentDetails.studentName + " -" + - "Physics Marks:" + " " + studentDetails.physicsMarks + " -" + - "Biology Marks:" + " " + studentDetails.biologyMarks + " -" + - "Maths Marks:" + " " + studentDetails.mathsMarks + " -" + - line ); - else - return(" - Records Not Found for ID " + id); - } - - public String getStudentGrade() - { - int id = Integer.parseInt(studentID2.getText()); - studentDetails.getStudentDetails(id); - String grade; - if(studentDetails.studentName == null) - { - System.out.println(" - Records Not Found for ID " + id); - return null; - } - if(studentDetails.physicsMarks < passMarks || -studentDetails.biologyMarks < passMarks || studentDetails.mathsMarks < -passMarks) - { - grade = "Failed"; - } - else - { - int avgMarks = (studentDetails.physicsMarks + -studentDetails.biologyMarks + studentDetails.mathsMarks)/3; - if(avgMarks >= passMarks && avgMarks < secondClass) grade = "Pass -Class"; - else if(avgMarks >= secondClass && avgMarks < firstClass) grade = -"Second Class"; - else if(avgMarks >= firstClass && avgMarks < topScore) grade = "First -Class"; - else grade = "Distinction"; - } - return(line + "Grade For " + studentDetails.studentName + " is " + grade -+ " -" + line); - } - - public String getNumberPasses() - { - int lastID = Registration.getNextID() -1; - boolean passed = true; - int numberPassed = 0; - for(int id = 1; id <= lastID; id++) - { - studentDetails.getStudentDetails(id); - if(studentDetails.physicsMarks >= passMarks && -studentDetails.biologyMarks >= passMarks && studentDetails.mathsMarks >= -passMarks) numberPassed++; - } - return(line + "Number of Student Passed: " + numberPassed + " -" + -line); - } - - public String getClassTopper() - { - int lastID = Registration.getNextID() -1; - String classTopper; - StringBuffer buffer = new StringBuffer(500); - int topMarks = 0; - for(int id = 1; id <= lastID; id++) - { - studentDetails.getStudentDetails(id); - int studentMarks = studentDetails.physicsMarks + -studentDetails.biologyMarks + studentDetails.mathsMarks; - if(studentMarks > topMarks) topMarks = studentMarks; - } - buffer.append(line + "Student Having Top Marks: -"); - for(int id = 1; id <= lastID; id++) - { - studentDetails.getStudentDetails(id); - int studentMarks = studentDetails.physicsMarks + -studentDetails.biologyMarks + studentDetails.mathsMarks; - if(studentMarks == topMarks) - { - buffer.append(studentDetails.studentName + " Having Total Marks: " + -topMarks + " -"); - } - } - buffer.append(line); - return(buffer.toString()); - } - - public void stateChanged(ChangeEvent e) - { - switch(tabbedPane.getSelectedIndex()) - { - case 3: studentPassed.setText(getNumberPasses()); - break; - case 4: studentTopper.setText(getClassTopper()); - break; - } - } - - public void actionPerformed(ActionEvent e) - { - if(e.getSource() == submitID1) - { - studentInfo.setText(getStudentInfo()); - } - else if(e.getSource() == submitID2) - { - studentGrade.setText(getStudentGrade()); - } - if(e.getSource() == submitDetails) - { - setStudentInfo(); - } - } - -} - - -//Registration Class -class Registration -{ - private int topScore = 90; - private int passMarks = 35; - private int firstClass = 65; - private int secondClass = 45; - private static String idFile = "id.dat"; - private static String studentFile = "studentfile.dat"; - - public int id; - public String studentName; - public int physicsMarks; - public int biologyMarks; - public int mathsMarks; - - public int addStudent(String studentName, int physicsMarks, int -biologyMarks, int mathsMarks) - { - int id = 0; - try - { - FileWriter fileOutput = new FileWriter(Registration.studentFile,true); - id = Registration.getNextID(); - String buffer = id + "|" + studentName + "|" + physicsMarks + "|" + -biologyMarks + "|" + mathsMarks + " -"; - fileOutput.write(buffer); - fileOutput.close(); - Registration.setID(id); - } - catch(IOException e) - { - System.err.println(e.toString()); - System.exit(1); - } - return id; - - } - -//Function to get the details of a student given the ID - public boolean getStudentDetails(int id) - { - try - { - FileReader fileInput = new FileReader(Registration.studentFile); - BufferedReader br = new BufferedReader(fileInput); - { - - String str; - while((str = br.readLine()) != null) - { - StringTokenizer fields = new StringTokenizer(str,"|"); - if(Integer.parseInt(fields.nextToken()) == id) - { - this.id = id; - this.studentName = fields.nextToken(); - this.physicsMarks = Integer.parseInt(fields.nextToken()); - this.biologyMarks = Integer.parseInt(fields.nextToken()); - this.mathsMarks = Integer.parseInt(fields.nextToken()); - return true; - } - } - } - - } - - catch(IOException e) - { - System.err.println(e.toString()); - System.exit(1); - } - - return false; - } - - public int getTopScore() - { - return topScore; - } - - public int getPassMarks() - { - return passMarks; - } - - public int getFirstClass() - { - return firstClass; - } - - public int getSecondClass() - { - return secondClass; - } - -//Function to get the next ID available - public static int getNextID() - { - int id = 0; - try - { - RandomAccessFile studentIDFile = new -RandomAccessFile(Registration.idFile,"rw"); - if(studentIDFile.length() == 0) - { - id = 0; - } - else id = studentIDFile.readInt(); - id++; - studentIDFile.close(); - } - - catch(IOException e) - { - System.err.println(e.toString()); - System.exit(1); - } - return id; - } - -//Function to Store current ID in a file - public static void setID(int id) - { - try - { - RandomAccessFile studentIDFile = new -RandomAccessFile(Registration.idFile,"rw"); - studentIDFile.seek(0); - studentIDFile.writeInt(id); - studentIDFile.close(); - } - - catch(IOException e) - { - System.err.println(e.toString()); - System.exit(1); - } - } -} diff --git a/java/_Basics/SelectionSort (Java).java b/java/_Basics/SelectionSort (Java).java deleted file mode 100644 index c1dc773..0000000 --- a/java/_Basics/SelectionSort (Java).java +++ /dev/null @@ -1,37 +0,0 @@ -public class SelectionSortExample -{ - public static void selectionSort(int[] arr) - { - for (int i = 0; i < arr.length - 1; i++) - { - int index = i; - for (int j = i + 1; j < arr.length; j++) - { - if (arr[j] < arr[index]) - { - index = j;//searching for lowest index - } - } - int smallerNumber = arr[index]; - arr[index] = arr[i]; - arr[i] = smallerNumber; - } - } - - public static void main(String a[]) - { - int[] arr1 = {9,14,3,2,43,11,58,22}; - System.out.println("Before Selection Sort"); - for(int i:arr1) - { - System.out.print(i+" "); - } - System.out.println(); - selectionSort(arr1);//sorting array using selection sort - System.out.println("After Selection Sort"); - for(int i:arr1) - { - System.out.print(i+" "); - } - } -} \ No newline at end of file diff --git a/java/_Basics/Set the foreground and background color to the tex.java b/java/_Basics/Set the foreground and background color to the tex.java deleted file mode 100644 index 619a8fc..0000000 --- a/java/_Basics/Set the foreground and background color to the tex.java +++ /dev/null @@ -1,186 +0,0 @@ -Set the foreground and background color to the text area - -import java.awt.*; -import java.awt.event.*; -import java.applet.*; - -class colopat extends Frame -{ - Checkbox r,g,b; - Checkbox m,y,gr,p,w,bl,c; - TextArea ta; - Checkbox r1,g1,b1; - Checkbox m1,y1,gr1,p1,w1,bl1,c1; - Label ba,fo; - Panel pa1,p2,p3; - - colopat() - { - setSize(800,600); - - setLayout(new BorderLayout()); - pa1=new Panel(new GridLayout(5,2,10,10)); - p2=new Panel(new GridLayout(5,2,10,10)); - - CheckboxGroup cbg=new CheckboxGroup(); - - r=new Checkbox("red",cbg,false); - g=new Checkbox("green",cbg,false); - b=new Checkbox("blue",cbg,false); - m=new Checkbox("megenta",cbg,false); - y=new Checkbox("yellow",cbg,false); - gr=new Checkbox("grey",cbg,false); - p=new Checkbox("pink",cbg,false); - w=new Checkbox("white",cbg,false); - bl=new Checkbox("black",cbg,true); - c=new Checkbox("cyan",cbg,false); - ba=new Label("BACKGROUND COLORS",Label.CENTER); - ba.setBackground(Color.pink); - - pa1.add(ba); - pa1.add(r); - pa1.add(b); - pa1.add(m); - pa1.add(y); - pa1.add(gr); - pa1.add(p); - pa1.add(w); - pa1.add(bl); - pa1.add(c); - add("West",pa1); - - ta=new TextArea(5,25); - p3=new Panel(new GridLayout(3,1)); - p3.add(new Label("Text Area",1)); - p3.add(ta); - add("Center",p3); - - r.addItemListener(new CheckBoxHandler(this)); - g.addItemListener(new CheckBoxHandler(this)); - b.addItemListener(new CheckBoxHandler(this)); - m.addItemListener(new CheckBoxHandler(this)); - y.addItemListener(new CheckBoxHandler(this)); - gr.addItemListener(new CheckBoxHandler(this)); - p.addItemListener(new CheckBoxHandler(this)); - w.addItemListener(new CheckBoxHandler(this)); - c.addItemListener(new CheckBoxHandler(this)); - bl.addItemListener(new CheckBoxHandler(this)); - - CheckboxGroup cbg1=new CheckboxGroup(); - r1=new Checkbox("red",cbg1,false); - g1=new Checkbox("green",cbg1,false); - b1=new Checkbox("blue",cbg1,false); - m1=new Checkbox("megenta",cbg1,false); - y1=new Checkbox("yellow",cbg1,false); - gr1=new Checkbox("grey",cbg1,false); - p1=new Checkbox("pink",cbg1,false); - w1=new Checkbox("white",cbg1,false); - bl1=new Checkbox("black",cbg1,true); - c1=new Checkbox("cyan",cbg1,false); - fo=new Label("FOREGROUND COLORS"); - fo.setBackground(Color.pink); - - p2.add(fo); - p2.add(c1); - p2.add(g1); - p2.add(b1); - p2.add(m1); - p2.add(y1); - p2.add(gr1); - p2.add(p1); - p2.add(w1); - p2.add(bl1); - p2.add(c1); - add("East",p2); - - r1.addItemListener(new CheckBoxHandler(this)); - g1.addItemListener(new CheckBoxHandler(this)); - b1.addItemListener(new CheckBoxHandler(this)); - m1.addItemListener(new CheckBoxHandler(this)); - y1.addItemListener(new CheckBoxHandler(this)); - gr1.addItemListener(new CheckBoxHandler(this)); - p1.addItemListener(new CheckBoxHandler(this)); - w1.addItemListener(new CheckBoxHandler(this)); - c1.addItemListener(new CheckBoxHandler(this)); - bl1.addItemListener(new CheckBoxHandler(this)); - c1.addItemListener(new CheckBoxHandler(this)); - - addWindowListener(new mywindowAdapter(this)); - - setVisible(true); - } - - public static void main(String args[]) - { - new colopat(); - } -} - -class CheckBoxHandler implements ItemListener -{ - colopat cp; - -CheckBoxHandler(colopat cp) -{ - this.cp=cp; -} -public void itemStateChanged(ItemEvent ie) -{ -if(cp.r.getState()) -cp.ta.setBackground(Color.red); -else if(cp.g.getState()) -cp.ta.setBackground(Color.green); -else if(cp.b.getState()) -cp.ta.setBackground(Color.blue); -else if(cp.m.getState()) -cp.ta.setBackground(Color.magenta); -else if(cp.y.getState()) -cp.ta.setBackground(Color.yellow); -else if(cp.gr.getState()) -cp.ta.setBackground(Color.lightGray); -else if(cp.bl.getState()) -cp.ta.setBackground(Color.black); -else if(cp.w.getState()) -cp.ta.setBackground(Color.white); -else if(cp.p.getState()) -cp.ta.setBackground(Color.pink); -else -cp.ta.setBackground(Color.cyan); - - -if(cp.r1.getState()) -cp.ta.setForeground(Color.red); -else if(cp.g1.getState()) -cp.ta.setForeground(Color.green); -else if(cp.b1.getState()) -cp.ta.setForeground(Color.blue); -else if(cp.m1.getState()) -cp.ta.setForeground(Color.magenta); -else if(cp.y1.getState()) -cp.ta.setForeground(Color.yellow); -else if(cp.gr1.getState()) -cp.ta.setForeground(Color.lightGray); -else if(cp.bl1.getState()) -cp.ta.setForeground(Color.black); -else if(cp.w1.getState()) -cp.ta.setForeground(Color.white); -else if(cp.p1.getState()) -cp.ta.setForeground(Color.pink); -else -cp.ta.setForeground(Color.cyan); -} -} - -class mywindowAdapter extends WindowAdapter -{ - colopat cp; - -mywindowAdapter(colopat cp) -{ - this.cp=cp; -} -public void windowClosing(WindowEvent e) -{ - System.exit(0); -} -} diff --git a/java/_Basics/Simple Arithmetic.java b/java/_Basics/Simple Arithmetic.java deleted file mode 100644 index 07cf95f..0000000 --- a/java/_Basics/Simple Arithmetic.java +++ /dev/null @@ -1,35 +0,0 @@ -Simple Arithmetic - - - - - -public class SimpleArithmetic { - public static void main( String[] args ) { - int withdraw = 300; - int deposit = 400; - - // declare and define using initialised variables - int balance = deposit - withdraw; - - // different way of adding 100 to balance - balance = balance + 100; - balance += 100; - - // use boolean - boolean isGood = false; - isGood = !isGood; // isGood is now true - - // remainder is one - int remainder = 100 % 3; - - // all operators have the = semantics - // so we have examles of /= and *= below - int value = 100 * 10; - value /= 5; - value *= 2; - - // and of course we can have compound arithmetic - int yourValue = ( ( value + balance ) / ( withdraw * deposit ) ); - } -} diff --git a/java/_Basics/Simple Inheritance.java b/java/_Basics/Simple Inheritance.java deleted file mode 100644 index 7dce554..0000000 --- a/java/_Basics/Simple Inheritance.java +++ /dev/null @@ -1,51 +0,0 @@ -Simple Inheritance - - - - - - -public class SimpleInheritance /* implicitly inherits from Object class */ { - // available to subclass and package level clients - protected int balance; - - public SimpleInheritance( String str ) { - System.out.println( "SimpleInheritance says: " + str ); - } - - public void message() { - - } -} - -class MySubclass extends SimpleInheritance { - // must define constructor because parent class - // does not define a default constructor - public MySubclass( String str ) { - // call the parent class's constructor - super( str ); - } - - // i've overriden the message method declared within SimpleInheritance - public void message() { - // but can call it by using the super keyword - super.message(); - - // i can also access non-private implementation, best not to have any - // in the first place, and expose through controlled accessor methods - System.out.println( super.balance ); - } -} - -class PackageLevelClient { - public PackageLevelClient() { - SimpleInheritance is = new MySubclass( "yo" ); - - // nasty, as a class in the package i can access - // all protected variables defined within this package, - // even though i'm not a part of the inheritance tree - // yuk, yuk, yuk, yuk!!!!!!!!!! - is.balance = 45; - } - -} diff --git a/java/_Basics/Simple Mathematical Calculations 2.java b/java/_Basics/Simple Mathematical Calculations 2.java deleted file mode 100644 index 0152059..0000000 --- a/java/_Basics/Simple Mathematical Calculations 2.java +++ /dev/null @@ -1,61 +0,0 @@ -Simple Mathematical Calculations 2 - -import java.awt.*; -import java.awt.event.*; - -// Java extension packages -import javax.swing.*; - -public class Points extends JApplet implements ActionListener { - JTextField x1Input, x2Input, y1Input, y2Input; - JLabel labelX1, labelY1, labelX2, labelY2; - - // set up GUI components - public void init() - { - labelX1 = new JLabel( "Enter X1: " ); - labelY1 = new JLabel( "Enter Y1: " ); - labelX2 = new JLabel( "Enter X2: " ); - labelY2 = new JLabel( "Enter Y2: " ); - x1Input = new JTextField( 4 ); - x2Input = new JTextField( 4 ); - y1Input = new JTextField( 4 ); - y2Input = new JTextField( 4 ); - y2Input.addActionListener( this ); - - Container container = getContentPane(); - container.setLayout( new FlowLayout() ); - container.add( labelX1 ); - container.add( x1Input ); - container.add( labelY1 ); - container.add( y1Input ); - container.add( labelX2 ); - container.add( x2Input ); - container.add( labelY2 ); - container.add( y2Input ); - } - - // display distance between user input points - public void actionPerformed( ActionEvent e ) - { - double x1, y1, x2, y2; - - // read in two points - x1 = Double.parseDouble( x1Input.getText() ); - y1 = Double.parseDouble( y1Input.getText() ); - x2 = Double.parseDouble( x2Input.getText() ); - y2 = Double.parseDouble( y2Input.getText() ); - - double theDistance = distance( x1, y1, x2, y2 ); - showStatus( "Distance is " + theDistance ); - } - - // calculate distance between two points - public double distance( double x1, double y1, - double x2, double y2 ) - { - return Math.sqrt( Math.pow( ( x1 - x2 ), 2 ) + - Math.pow( ( y1 - y2 ), 2 ) ); - } - -} // end class Points diff --git a/java/_Basics/Simple Mathematical Calculations.java b/java/_Basics/Simple Mathematical Calculations.java deleted file mode 100644 index 52ed13b..0000000 --- a/java/_Basics/Simple Mathematical Calculations.java +++ /dev/null @@ -1,51 +0,0 @@ -Simple Mathematical Calculations - -// Exercise 3.12 Solution: Multiples.java -// Given two doubles as input, the program determines if the first// is a multiple of the second. - -// Java core packages -import java.awt.Graphics; // import class Graphics - -// Java extension packages -import javax.swing.*; // import package javax.swing - -public class Multiples extends JApplet { - String result; // output display String - - // initialize applet by obtaining values from user - public void init() - { - String firstNumber; // first String entered by user - String secondNumber; // second String entered by user - double number1; // first number to compare - double number2; // second number to compare - - // read first number from user as a String - firstNumber = - JOptionPane.showInputDialog( "Enter first floating-point number:" ); - - // read second number from user as a String - secondNumber = - JOptionPane.showInputDialog( "Enter second floating-point number:" ); - - // convert numbers from type String to type double - number1 = Double.parseDouble( firstNumber ); - number2 = Double.parseDouble( secondNumber ); - - if ( number1 % number2 == 0 ) - result = number1 + " is a multiple of " + number2; - - if ( number1 % number2 != 0 ) - result = number1 + " is not a multiple of " + number2; - - } // end method init - - // draw results on applet's background - public void paint( Graphics g ) - { - // draw result as a String at (25, 25) - g.drawString( result, 25, 25 ); - - } // end method paint - -} // end class OddEven diff --git a/java/_Basics/Simple Strings.java b/java/_Basics/Simple Strings.java deleted file mode 100644 index 20e7686..0000000 --- a/java/_Basics/Simple Strings.java +++ /dev/null @@ -1,79 +0,0 @@ -Simple Strings - - - - - -/** - * messing about with Java Strings - */ -public class SimpleStrings { - public static void main( String[] args ) { - // a string is a array of characters - char[] helloChars = {'h', 'e', 'l', 'l', 'o'}; - String helloString = new String( helloChars ); - System.out.println( helloString ); - - // best way to assign a string literal - helloString = "hello"; - - // no need to do this - helloString = new String( "hello" ); - - // an example - String barryWhite = "i love you all!"; - System.out.println( barryWhite.length() ); // 15 - System.out.println( barryWhite.charAt( 0 ) ); // i - System.out.println( barryWhite.startsWith( "i love" ) ); // true - System.out.println( barryWhite.endsWith( "all" ) ); // false - System.out.println( barryWhite.indexOf( 'l' ) ); // 2 - System.out.println( barryWhite.indexOf( "you" ) ); // 7 - System.out.println( barryWhite.substring( 7 ) ); // you all! - System.out.println( barryWhite.substring( 3, 8 ) ); // ove y - - // String equality - String a = "hello"; - String b = "world"; - String c = new String( "hello" ); - String d = a; - - // == between Java objects is on reference equality - // equals() method is used to value equality - System.out.println( a == b ); // false - System.out.println( a == c ); // false - System.out.println( a.equals( c ) ); // true - System.out.println( a == d ); // true - - // String are immutable - String noChange = "have i changed, not likely"; - - noChange.substring( 3 ); - noChange.toLowerCase(); - noChange.toUpperCase(); - noChange.trim(); - System.out.println( noChange ); // have i changed, not likely - - // StringBuffer usage - StringBuffer buffer = new StringBuffer(); - for( int i = 0; i < 10; i++ ) { - buffer.append( "say hello: " ); - buffer.append( i ); - buffer.append( "\n" ); - } - - System.out.println( buffer ); - /** - * this outputs - * say hello: 0 - * say hello: 1 - * say hello: 2 - * say hello: 3 - * say hello: 4 - * say hello: 5 - * say hello: 6 - * say hello: 7 - * say hello: 8 - * say hello: 9 - */ - } -} diff --git a/java/_Basics/SimpleWordCounter (Java).java b/java/_Basics/SimpleWordCounter (Java).java deleted file mode 100644 index d833f46..0000000 --- a/java/_Basics/SimpleWordCounter (Java).java +++ /dev/null @@ -1,39 +0,0 @@ -// Program demonstrating use of a map to count the frequency of words in a file. - -import java.io.File; -import java.io.IOException; -import java.util.Map; -import java.util.Scanner; -import java.util.TreeMap; - -public class SimpleWordCounter -{ - - public static void main(String[] args) - { - try - { - File f = new File("ciaFactBook2008.txt"); - Scanner sc; - sc = new Scanner(f); - // sc.useDelimiter("[^a-zA-Z']+"); - Map wordCount = new TreeMap(); - while(sc.hasNext()) - { - String word = sc.next(); - if(!wordCount.containsKey(word)) - wordCount.put(word, 1); - else - wordCount.put(word, wordCount.get(word) + 1); - } - // show results - for(String word : wordCount.keySet()) - System.out.println(word + " " + wordCount.get(word)); - System.out.println(wordCount.size()); - } - catch(IOException e) - { - System.out.println("Unable to read from file."); - } - } -} diff --git a/java/_Basics/Stop watch programme.java b/java/_Basics/Stop watch programme.java deleted file mode 100644 index 44c08a2..0000000 --- a/java/_Basics/Stop watch programme.java +++ /dev/null @@ -1,83 +0,0 @@ -Stop watch programme - -import java.awt.event.*; -import java.awt.*; -import javax.swing.*; - -public class Stopwatch extends JFrame implements ActionListener, Runnable - { - private long startTime; - private final static java.text.SimpleDateFormat timerFormat = new java.text.SimpleDateFormat("mm : ss.SSS"); - private final JButton startStopButton= new JButton("Start/stop"); - private Thread updater; - private boolean isRunning= false; - private final Runnable displayUpdater= new Runnable() - { - public void run() - { - displayElapsedTime(System.currentTimeMillis() - Stopwatch.this.startTime); - } - }; - public void actionPerformed(ActionEvent ae) - { - if(isRunning) - { - long elapsed= System.currentTimeMillis() - startTime; - isRunning= false; - try - { - updater.join(); - // Wait for updater to finish - } - catch(InterruptedException ie) {} - displayElapsedTime(elapsed); - // Display the end-result - } - else - { - startTime= System.currentTimeMillis(); - isRunning= true; - updater= new Thread(this); - updater.start(); - } - } - private void displayElapsedTime(long elapsedTime) - { - startStopButton.setText(timerFormat.format(new java.util.Date(elapsedTime))); - } - public void run() - { - try - { - while(isRunning) - { - SwingUtilities.invokeAndWait(displayUpdater); - Thread.sleep(50); - } - } - catch(java.lang.reflect.InvocationTargetException ite) - { - ite.printStackTrace(System.err); - // Should never happen! - } - catch(InterruptedException ie) {} - // Ignore and return! - } - public Stopwatch() - { - startStopButton.addActionListener(this); - getContentPane().add(startStopButton); - setSize(100,50); - setVisible(true); - } - public static void main(String[] arg) - { - new Stopwatch().addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent e) - { - System.exit(0); - } - }); - } -} diff --git a/java/_Basics/StringFunctions.java b/java/_Basics/StringFunctions.java deleted file mode 100644 index ceca506..0000000 --- a/java/_Basics/StringFunctions.java +++ /dev/null @@ -1,308 +0,0 @@ -package com.jwetherell.algorithms.strings; - -import java.util.BitSet; -import java.util.StringTokenizer; - -/** - * This class contains methods for modifying text. - * - * @author Justin Wetherell - */ -public class StringFunctions { - - private static final char SPACE = ' '; - - public static final String reverseWithStringConcat(String string) { - String output = new String(); - for (int i = (string.length() - 1); i >= 0; i--) { - output += (string.charAt(i)); - } - return output; - } - - public static final String reverseWithStringBuilder(String string) { - final StringBuilder builder = new StringBuilder(); - for (int i = (string.length() - 1); i >= 0; i--) { - builder.append(string.charAt(i)); - } - return builder.toString(); - } - - public static final String reverseWithStringBuilderBuiltinMethod(String string) { - final StringBuilder builder = new StringBuilder(string); - return builder.reverse().toString(); - } - - public static final String reverseWithSwaps(String string) { - final char[] array = string.toCharArray(); - final int length = array.length - 1; - final int half = (int) Math.floor(array.length / 2); - - char c; - for (int i = length; i >= half; i--) { - c = array[length - i]; - array[length - i] = array[i]; - array[i] = c; - } - return String.valueOf(array); - } - - public static final String reverseWithXOR(String string) { - final char[] array = string.toCharArray(); - final int length = array.length; - final int half = (int) Math.floor(array.length / 2); - - for (int i = 0; i < half; i++) { - array[i] ^= array[length - i - 1]; - array[length - i - 1] ^= array[i]; - array[i] ^= array[length - i - 1]; - } - return String.valueOf(array); - } - - public static final String reverseWordsByCharWithAdditionalStorage(String string) { - final StringBuilder builder = new StringBuilder(); - final int length = string.length() - 1; - final StringBuilder temp = new StringBuilder(); - - char c = 0; - int index = 0; - int last = string.length(); - for (int i = length; i >= 0; i--) { - c = string.charAt(i); - if (c == SPACE || i == 0) { - index = (i == 0) ? 0 : i + 1; - temp.append(string.substring(index, last)); - if (index != 0) - temp.append(c); - builder.append(temp); - temp.delete(0, temp.length()); - last = i; - } - } - - return builder.toString(); - } - - public static final String reverseWordsUsingStringTokenizerWithAdditionalStorage(String string) { - final StringTokenizer st = new StringTokenizer(string); - String output = new String(); - while (st.hasMoreTokens()) { - output = (st.nextToken()) + ' ' + output; - } - - return output.trim(); - } - - public static final String reverseWordsUsingSplitWithAdditionalStorage(String string) { - final StringBuilder builder = new StringBuilder(); - final String[] temp = string.split(" "); - - for (int i = (temp.length - 1); i >= 0; i--) { - builder.append(temp[i]).append(' '); - } - return builder.toString().trim(); - } - - public static final String reverseWordsInPlace(String string) { - char[] chars = string.toCharArray(); - - int lengthI = 0; - int lastI = 0; - int lengthJ = 0; - int lastJ = chars.length - 1; - - int i = 0; - char iChar = 0; - char jChar = 0; - while (i < chars.length && i <= lastJ) { - iChar = chars[i]; - if (iChar == SPACE) { - lengthI = i - lastI; - for (int j = lastJ; j >= i; j--) { - jChar = chars[j]; - if (jChar == SPACE) { - lengthJ = lastJ - j; - swapWords(lastI, i - 1, j + 1, lastJ, chars); - lastJ = lastJ - lengthI - 1; - break; - } - } - lastI = lastI + lengthJ + 1; - i = lastI; - } else { - i++; - } - } - - return String.valueOf(chars); - } - - private static final void swapWords(int startA, int endA, int startB, int endB, char[] array) { - int lengthA = endA - startA + 1; - int lengthB = endB - startB + 1; - - int length = lengthA; - if (lengthA > lengthB) - length = lengthB; - - int indexA = 0; - int indexB = 0; - char c = 0; - for (int i = 0; i < length; i++) { - indexA = startA + i; - indexB = startB + i; - - c = array[indexB]; - array[indexB] = array[indexA]; - array[indexA] = c; - } - - if (lengthB > lengthA) { - length = lengthB - lengthA; - int end = 0; - for (int i = 0; i < length; i++) { - end = endB - ((length - 1) - i); - c = array[end]; - shiftRight(endA + i, end, array); - array[endA + 1 + i] = c; - } - } else if (lengthA > lengthB) { - length = lengthA - lengthB; - for (int i = 0; i < length; i++) { - c = array[endA]; - shiftLeft(endA, endB, array); - array[endB + i] = c; - } - } - } - - private static final void shiftRight(int start, int end, char[] array) { - for (int i = end; i > start; i--) { - array[i] = array[i - 1]; - } - } - - private static final void shiftLeft(int start, int end, char[] array) { - for (int i = start; i < end; i++) { - array[i] = array[i + 1]; - } - } - - public static final boolean isPalindromeWithAdditionalStorage(String string) { - final String reversed = new StringBuilder(string).reverse().toString(); - return string.equals(reversed); - } - - public static final boolean isPalindromeInPlace(String string) { - final char[] array = string.toCharArray(); - final int length = array.length - 1; - final int half = Math.round(array.length / 2); - char a, b; - for (int i = length; i >= half; i--) { - a = array[length - i]; - b = array[i]; - if (a != b) - return false; - } - return true; - } - - public static final String[] generateSubsets(String inputString) { - final int length = inputString.length(); - final int size = (int) Math.pow(2, length); - final BitSet[] sets = new BitSet[size]; - final String[] output = new String[size]; - - for (int i = 0; i < size; i++) { - final BitSet set = new BitSet(size); - final StringBuilder builder = new StringBuilder(); - if (i > 0) { - for (int j = length - 1; j >= 0; j--) { - if (j == length - 1) { - if (i % 2 != 0) - set.set(j, true); - } else { - boolean prev = sets[i - 1].get(j); - boolean next = true; - for (int k = j + 1; k < length; k++) { - next = next && sets[i - 1].get(k); - } - if (next) - prev = !prev; - set.set(j, prev); - } - if (set.get(j)) - builder.append(inputString.charAt(j)); - } - } - sets[i] = set; - output[i] = builder.toString(); - } - return output; - } - - /** recursive **/ - public static final int levenshteinDistanceRecursive(String s, String t) { - final int sLength = s.length(); - final int tLength = t.length(); - final char[] sChars = s.toCharArray(); - final char[] tChars = t.toCharArray(); - - int cost = 0; - if ((sLength > 0 && tLength > 0) && sChars[0] != tChars[0]) - cost = 1; - - if (sLength == 0) - return tLength; - else if (tLength == 0) - return sLength; - else { - final int min1 = levenshteinDistanceRecursive(s.substring(1), t) + 1; - final int min2 = levenshteinDistanceRecursive(s, t.substring(1)) + 1; - final int min3 = levenshteinDistanceRecursive(s.substring(1), t.substring(1)) + cost; - - int minOfFirstSet = Math.min(min1, min2); - return (Math.min(minOfFirstSet, min3)); - } - } - - /** iterative - dynamic programming **/ - public static final int levenshteinDistanceIterative(String string1, String string2) { - final char[] s = string1.toCharArray(); - final char[] t = string2.toCharArray(); - final int m = s.length; - final int n = t.length; - - // for all i and j, d[i,j] will hold the Levenshtein distance between - // the first i characters of s and the first j characters of t - // note that d has (m+1)*(n+1) values - final int[][] d = new int[m+1][n+1]; - - // source prefixes can be transformed into empty string by - // dropping all characters - for (int i=1; i<=m; i++) - d[i][0] = i; - - // target prefixes can be reached from empty source prefix - // by inserting every character - for (int j=1; j<=n; j++) - d[0][j] = j; - - int substitutionCost; - for (int j=1; j<=n; j++) { - for (int i=1; i<=m; i++) { - if (s[i-1] == t[j-1]) - substitutionCost = 0; - else - substitutionCost = 1; - - int minOfInsAndDel = Math.min(d[i-1][j] + 1, // deletion - d[i][j-1] + 1); // insertion - d[i][j] = Math.min(minOfInsAndDel, // minimum of insert and delete - d[i-1][j-1] + substitutionCost); // substitution - } - } - return d[m][n]; - } -} diff --git a/java/_Basics/SubsequenceCounter.java b/java/_Basics/SubsequenceCounter.java deleted file mode 100644 index 3449cb9..0000000 --- a/java/_Basics/SubsequenceCounter.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.jwetherell.algorithms.sequence; - -/** - * Finds the number of times a string occurs as a subsequence in a text. - *

- * http://www.geeksforgeeks.org/find-number-times-string-occurs-given-string/ - *
- * @author Justin Wetherell - */ -public class SubsequenceCounter { - - private static char[] seq = null; - private static char[] subseq = null; - private static int[][] tbl = null; - - private SubsequenceCounter() { } - - /** - * Finds the number of times a string occurs as a subsequence in a text. - * - * @param sequence Text to find subsequence in. - * @param subSequence subsequence to find in the text. - * @return Number of times a string occurs as a subsequence in a text - */ - public static int getCount(char[] sequence, char[] subSequence) { - try { - seq = sequence; - subseq = subSequence; - tbl = new int[seq.length + 1][subseq.length + 1]; - - for (int row = 0; row < tbl.length; row++) - for (int col = 0; col < tbl[row].length; col++) - tbl[row][col] = countMatches(row, col); - - return tbl[seq.length][subseq.length]; - } finally { - seq = null; - subseq = null; - tbl = null; - } - } - - private static int countMatches(int seqDigitsLeft, int subseqDigitsLeft) { - if (subseqDigitsLeft == 0) - return 1; - - if (seqDigitsLeft == 0) - return 0; - - final char currSeqDigit = seq[seq.length - seqDigitsLeft]; - final char currSubseqDigit = subseq[subseq.length - subseqDigitsLeft]; - - int result = 0; - if (currSeqDigit == currSubseqDigit) - result += tbl[seqDigitsLeft - 1][subseqDigitsLeft - 1]; - result += tbl[seqDigitsLeft - 1][subseqDigitsLeft]; - - return result; - } -} diff --git a/java/_Basics/Swap two numbers.java b/java/_Basics/Swap two numbers.java deleted file mode 100644 index 3d2d87b..0000000 --- a/java/_Basics/Swap two numbers.java +++ /dev/null @@ -1,22 +0,0 @@ - import java.util.Scanner; - - class SwapNumbers - { - public static void main(String args[]) - { - int x, y, temp; - System.out.println("Enter x and y"); - Scanner in = new Scanner(System.in); - - x = in.nextInt(); - y = in.nextInt(); - - System.out.println("Before Swapping\nx = "+x+"\ny = "+y); - - temp = x; - x = y; - y = temp; - - System.out.println("After Swapping\nx = "+x+"\ny = "+y); - } - } \ No newline at end of file diff --git a/java/_Basics/Switch Statements.java b/java/_Basics/Switch Statements.java deleted file mode 100644 index fe4f94d..0000000 --- a/java/_Basics/Switch Statements.java +++ /dev/null @@ -1,57 +0,0 @@ -Switch Statements - - - - - -public class SwitchStatements { - public static void main( String[] args ) { - int amount = 10; - - // simple switch statement - switch( amount ) { - case 1: - System.out.println( "amount is 1" ); - break; - case 2: - System.out.println( "amount is 2" ); - break; - default: - System.out.println( "don't care about amount" ); - } - - // more complicated switch statement - switch( amount ) { - case 1: - System.out.println( "amount was 1" ); - break; - - case 10: - case 4: - case 3: - if( amount == 10 ) { - System.out.println( "amount was ten" ); - } - else { - System.out.println( "amount was 4 or 3, actually -> " + amount ); - } - break; - - default: - System.out.println( "default action" ); - } - - // switch on a char - char c = 't'; - switch( c ) { - case 'b': - System.out.println( "hit the b character" ); - break; - case 't': - System.out.println( "hit the t character" ); - break; - default: - System.out.println( "unsupported character" ); - } - } -} diff --git a/java/_Basics/This is a simple text clock.java b/java/_Basics/This is a simple text clock.java deleted file mode 100644 index cdb8878..0000000 --- a/java/_Basics/This is a simple text clock.java +++ /dev/null @@ -1,60 +0,0 @@ -This is a simple text clock. See - -javax.swing.Timer for an explanation of how use this simple timer class. - - - - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; -import java.util.Calendar; // only need this one class - -/// TextClock -public class TextClock { - -main - public static void main(String[] args) { - JFrame clock = new TextClockWindow(); - clock.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - clock.setVisible(true); - }//end main -}//endclass TextClock - - -////// TextClockWindow -class TextClockWindow extends JFrame { - -instance variables - private JTextField timeField; // set by timer listener - - -constructor - public TextClockWindow() { - // Build the GUI - only one panel - timeField = new JTextField(6); - timeField.setFont(new Font("sansserif", Font.PLAIN, 48)); - - Container content = this.getContentPane(); - content.setLayout(new FlowLayout()); - content.add(timeField); - - this.setTitle("Text Clock"); - this.pack(); - - // Create a 1-second timer and action listener for it. - // Specify package because there are two Timer classes - javax.swing.Timer t = new javax.swing.Timer(1000, - new ActionListener() { - public void actionPerformed(ActionEvent e) { - Calendar now = Calendar.getInstance(); - int h = now.get(Calendar.HOUR_OF_DAY); - int m = now.get(Calendar.MINUTE); - int s = now.get(Calendar.SECOND); - timeField.setText("" + h + ":" + m + ":" + s); - } - }); - t.start(); // Start the timer - }//end constructor -}//endclass TextClock diff --git a/java/_Basics/TimeQuery.java b/java/_Basics/TimeQuery.java deleted file mode 100644 index c9ade1d..0000000 --- a/java/_Basics/TimeQuery.java +++ /dev/null @@ -1,83 +0,0 @@ -TimeQuery - - - -import java.io.*; -import java.net.*; -import java.nio.*; -import java.nio.channels.*; -import java.nio.charset.*; -import java.util.regex.*; - - -public class TimeQuery { - - // The standard daytime port - private static int DAYTIME_PORT = 13; - - // The port we'll actually use - private static int port = DAYTIME_PORT; - - // Charset and decoder for US-ASCII - private static Charset charset = Charset.forName("US-ASCII"); - private static CharsetDecoder decoder = charset.newDecoder(); - - // Direct byte buffer for reading - private static ByteBuffer dbuf = ByteBuffer.allocateDirect(1024); - - // Ask the given host what time it is - // - private static void query(String host) throws IOException { - InetSocketAddress isa - = new InetSocketAddress(InetAddress.getByName(host), port); - SocketChannel sc = null; - - try { - - // Connect - sc = SocketChannel.open(); - sc.connect(isa); - - // Read the time from the remote host. For simplicity we assume - // that the time comes back to us in a single packet, so that we - // only need to read once. - dbuf.clear(); - sc.read(dbuf); - - // Print the remote address and the received time - dbuf.flip(); - CharBuffer cb = decoder.decode(dbuf); - System.out.print(isa + " : " + cb); - - } finally { - // Make sure we close the channel (and hence the socket) - if (sc != null) - sc.close(); - } - } - - public static void main(String[] args) { - if (args.length < 1) { - System.err.println("Usage: java TimeQuery [port] host..."); - return; - } - int firstArg = 0; - - // If the first argument is a string of digits then we take that - // to be the port number - if (Pattern.matches("[0-9]+", args[0])) { - port = Integer.parseInt(args[0]); - firstArg = 1; - } - - for (int i = firstArg; i < args.length; i++) { - String host = args[i]; - try { - query(host); - } catch (IOException x) { - System.err.println(host + ": " + x); - } - } - } - -} diff --git a/java/_Basics/TimeServer.java b/java/_Basics/TimeServer.java deleted file mode 100644 index e20368b..0000000 --- a/java/_Basics/TimeServer.java +++ /dev/null @@ -1,74 +0,0 @@ -TimeServer - - - -import java.io.*; -import java.net.*; -import java.nio.*; -import java.nio.channels.*; -import java.nio.charset.*; -import java.util.*; -import java.util.regex.*; - - -public class TimeServer { - - // We can't use the normal daytime port (unless we're running as root, - // which is unlikely), so we use this one instead - private static int PORT = 8013; - - // The port we'll actually use - private static int port = PORT; - - // Charset and encoder for US-ASCII - private static Charset charset = Charset.forName("US-ASCII"); - private static CharsetEncoder encoder = charset.newEncoder(); - - // Direct byte buffer for writing - private static ByteBuffer dbuf = ByteBuffer.allocateDirect(1024); - - - // Open and bind the server-socket channel - // - private static ServerSocketChannel setup() throws IOException { - ServerSocketChannel ssc = ServerSocketChannel.open(); - InetSocketAddress isa - = new InetSocketAddress(InetAddress.getLocalHost(), port); - ssc.socket().bind(isa); - return ssc; - } - - // Service the next request to come in on the given channel - // - private static void serve(ServerSocketChannel ssc) throws IOException { - SocketChannel sc = ssc.accept(); - try { - String now = new Date().toString(); - sc.write(encoder.encode(CharBuffer.wrap(now + " -"))); - System.out.println(sc.socket().getInetAddress() + " : " + now); - sc.close(); - } finally { - // Make sure we close the channel (and hence the socket) - sc.close(); - } - } - - public static void main(String[] args) throws IOException { - if (args.length > 1) { - System.err.println("Usage: java TimeServer [port]"); - return; - } - - // If the first argument is a string of digits then we take that - // to be the port number - if ((args.length == 1) && Pattern.matches("[0-9]+", args[0])) - port = Integer.parseInt(args[0]); - - ServerSocketChannel ssc = setup(); - for (;;) - serve(ssc); - - } - -} diff --git a/java/_Basics/Timer.java b/java/_Basics/Timer.java deleted file mode 100644 index 9abb421..0000000 --- a/java/_Basics/Timer.java +++ /dev/null @@ -1,19 +0,0 @@ -Timer - - - -package com.ack.webservices.soap.examples.handlers; - -import java.util.Calendar; -import java.util.Date; - -public class Timer { - public void sendTime( Date theTime ) { - System.out.println( "time on client: " + theTime ); - } - - public Date getTime() { - // return time on server - return Calendar.getInstance().getInstance().getTime(); - } -} diff --git a/java/_Basics/TimerClient.java b/java/_Basics/TimerClient.java deleted file mode 100644 index 1c8b94a..0000000 --- a/java/_Basics/TimerClient.java +++ /dev/null @@ -1,55 +0,0 @@ -TimerClient - - - -package com.ack.webservices.soap.examples.handlers; - -import java.util.Calendar; -import java.util.Date; - -import org.apache.axis.client.Call; -import org.apache.axis.client.Service; - -public class TimerClient { - public static void main( String[] args ) throws Exception { - String endpoint = "http://localhost:8080/axis/services/TimerService"; - - /** - * call the getTime to find out the time on the server - */ - - // calls are created our a service, that is typically associated, - // but not necessarily, with a WSDL file - Service service = new Service(); - Call call = (Call) service.createCall(); - - // set in the target endpoint, operation name, and request intent - call.setTargetEndpointAddress( new java.net.URL( endpoint ) ); - call.setOperationName( "getTime" ); - - // Axis provides a nicely overloaded invoke that delivered the return value - Date ret = (Date) call.invoke( new Object[]{} ); - - // then just print it out - System.out.println( "time on server: " + ret ); - - /** - * call the sendTime to pass the time on the client to the server - * note: check the soap server's console for the output. - * - * note: Be sure to check what is returned to the client from the server - * when an invokeOneWay() is called. Do this be uses the TraceMessageHandler - * in the of the TimeService. - */ - - call = (Call) service.createCall(); - - // set in the target endpoint, operation name, and request intent - call.setTargetEndpointAddress( new java.net.URL( endpoint ) ); - call.setOperationName( "sendTime" ); - - // send the time on the client to the server, in a one way method call - Date clientDate = Calendar.getInstance().getTime(); - call.invokeOneWay( new Object[]{clientDate} ); - } -} diff --git a/java/_Basics/To compare two strings.java b/java/_Basics/To compare two strings.java deleted file mode 100644 index 7be2210..0000000 --- a/java/_Basics/To compare two strings.java +++ /dev/null @@ -1,23 +0,0 @@ - import java.util.Scanner; - - class CompareStrings - { - public static void main(String args[]) - { - String s1, s2; - Scanner in = new Scanner(System.in); - - System.out.println("Enter the first string"); - s1 = in.nextLine(); - - System.out.println("Enter the second string"); - s2 = in.nextLine(); - - if ( s1.compareTo(s2) > 0 ) - System.out.println("First string is greater than second."); - else if ( s1.compareTo(s2) < 0 ) - System.out.println("First string is smaller than second."); - else - System.out.println("Both strings are equal."); - } - } \ No newline at end of file diff --git a/java/_Basics/To find all substrings of a string.java b/java/_Basics/To find all substrings of a string.java deleted file mode 100644 index c2765a0..0000000 --- a/java/_Basics/To find all substrings of a string.java +++ /dev/null @@ -1,28 +0,0 @@ - Java programing code - import java.util.Scanner; - - class SubstringsOfAString - { - public static void main(String args[]) - { - String string, sub; - int i, c, length; - - Scanner in = new Scanner(System.in); - System.out.println("Enter a string to print it's all substrings"); - string = in.nextLine(); - - length = string.length(); - - System.out.println("Substrings of \""+string+"\" are :-"); - - for( c = 0 ; c < length ; c++ ) - { - for( i = 1 ; i <= length - c ; i++ ) - { - sub = string.substring(c, c+i); - System.out.println(sub); - } - } - } - } \ No newline at end of file diff --git a/java/_Basics/To reverse a string.java b/java/_Basics/To reverse a string.java deleted file mode 100644 index f1c0eb6..0000000 --- a/java/_Basics/To reverse a string.java +++ /dev/null @@ -1,20 +0,0 @@ - import java.util.*; - - class ReverseString - { - public static void main(String args[]) - { - String original, reverse = ""; - Scanner in = new Scanner(System.in); - - System.out.println("Enter a string to reverse"); - original = in.nextLine(); - - int length = original.length(); - - for ( int i = length - 1 ; i >= 0 ; i-- ) - reverse = reverse + original.charAt(i); - - System.out.println("Reverse of entered string is: "+reverse); - } - } \ No newline at end of file diff --git a/java/_Basics/Transfer Account.java b/java/_Basics/Transfer Account.java deleted file mode 100644 index bd8b39d..0000000 --- a/java/_Basics/Transfer Account.java +++ /dev/null @@ -1,24 +0,0 @@ -Transfer Account - - - -package com.ack.learning.examples.account; - -public class TransferAccount { - private static int count; - - public TransferAccount() { - ++TransferAccount.count; - } - - public static int getObjectCount() { - return TransferAccount.count; - } - - public static void main( String[] args ) { - TransferAccount ta = new TransferAccount(); - TransferAccount da = new TransferAccount(); - - System.out.println( TransferAccount.getObjectCount() ); - } -} diff --git a/java/_Basics/Try Finally.java b/java/_Basics/Try Finally.java deleted file mode 100644 index 22ce625..0000000 --- a/java/_Basics/Try Finally.java +++ /dev/null @@ -1,21 +0,0 @@ -Try Finally - - - - - -public class TryFinally { - public static void main( String[] args ) throws Exception { - // important to note that try, does not always need - // to be accompanied by a catch block - try { - // if an exception is raised the finally block is - // executed and the exception propogates out, hence - // note the Exception on the main method's throw clause - throw new Exception( "oopsy" ); - } - finally { - System.out.println( "no worries, i'm always called" ); - } - } -} diff --git a/java/_Basics/Try Pie Finally.java b/java/_Basics/Try Pie Finally.java deleted file mode 100644 index d6e8234..0000000 --- a/java/_Basics/Try Pie Finally.java +++ /dev/null @@ -1,33 +0,0 @@ -Try Pie Finally - - - -package com.ack.learning.exceptions; - -import com.ack.learning.exceptions.PieEater; -import com.ack.learning.exceptions.PieException; - -public class TryPieFinally { - public static void main( String[] args ) throws PieException { - - // in this example, you have decided not to handle - // PieExceptions raised in the try block. - - // When a PieException occurs, the finally block code - // is executed and the exception propagates up the - // method stack to main(), which we see can throw PieException - - // The JVM seeing that main() is the program entry point, catches - // the exception, dumps out its stack trace and ends the program - - // note: better to always handle application specific errors - try { - PieEater pe = new PieEater(); - // eat over a 100 pies - System.out.println( pe.howManyPies() ); - } - finally { - System.out.println( "no more pies" ); - } - } -} diff --git a/java/_Basics/Type Casting.java b/java/_Basics/Type Casting.java deleted file mode 100644 index 628cc37..0000000 --- a/java/_Basics/Type Casting.java +++ /dev/null @@ -1,35 +0,0 @@ -Type Casting - - - - - -public class TypeCasting { - public static void main( String[] args ) { - // implicit cast - - // will allow if the right-hand side (rhs) value is small enough - short smallValue = 45; - - // this is not allowed because rhs value is too big for a short - //smallValue = 234251434324324; - - // assigning a short to an integer is an implicit cast and - // one the compiler can handle because ints are bigger than shorts - int littleValue = smallValue; - - // assigning a integer to short requires an explicit cast because - // shorts are smaller than ints and they would a loss of precision - smallValue = (short) littleValue; - - // specify typed literal values using L, F and D - // ( and their lowercase equivalents ) - float pay = 42234.45f; - long bigValue = 45243224L; - double amount = 345.45d; - - // default literal values - int defaultIsInt = 345; - double defaultIsDouble = 34.5; - } -} diff --git a/java/_Basics/Use of Runtime Class.java b/java/_Basics/Use of Runtime Class.java deleted file mode 100644 index b0adc4a..0000000 --- a/java/_Basics/Use of Runtime Class.java +++ /dev/null @@ -1,32 +0,0 @@ -Use of Runtime Class - -import java.io.*; -class test extends Thread -{ - public void run() - { - Runtime r=Runtime.getRuntime(); - Process p=null; - try - { - for(int i=0;i<=100;i++) - { - p=r.exec("net send vishal how r u!"); - //p.waitFor(); - Thread.sleep(5000); - } - } - catch(Exception e) - { - System.out.println(e); - } - } - - public static void main(String args[]) - { - test t=new test(); - t.run(); - - } - -} diff --git a/java/_Basics/Using Primitive Arrays.java b/java/_Basics/Using Primitive Arrays.java deleted file mode 100644 index 61dc682..0000000 --- a/java/_Basics/Using Primitive Arrays.java +++ /dev/null @@ -1,43 +0,0 @@ -Using Primitive Arrays - - - - - -public class UsingPrimitiveArrays { - public static void main( String[] args ) { - // declare an array - int[] bags; - - // create and assign array with 10 elements - bags = new int[5]; - - // declare, create and assign array in one step - float[] balances = new float[4]; - - /** - * Note that both the 'bags' and 'balances' arrays - * are initialised with the default values which for - * ints and float are zero - */ - - // assign bags new values - bags = new int[]{5, 10, 15, 20, 25}; - - // here is a shorthand for declaring an array, - // and assigning values. note that the omission - // of the new statement can only be done if declaration - // and assignment take place within one statement - int[] sacks = {1, 2, 3, 4, 5}; - - // and to get the length of the array - // java provides a special property on arrays - // NOTE: length is not a method, hence no parenthesis - System.out.println( "The number of sacks is: " + sacks.length ); - - // accessing arrays - for( int i = 0; i < bags.length; i++ ) { - System.out.println( bags[i] ); - } - } -} diff --git a/java/_Basics/While Loops.java b/java/_Basics/While Loops.java deleted file mode 100644 index 29bf0e7..0000000 --- a/java/_Basics/While Loops.java +++ /dev/null @@ -1,30 +0,0 @@ -While Loops - - - - - -public class WhileLoops { - public static void main( String[] args ) { - // simple loop that goes round and around until - // expression evaluations to false - double index = 99999; - while( index > 10 ) { - System.out.println( "index has value " + index ); - index /= 2; - } - - // this would be an infinite loop... - while( true ) { - break; // ...if we didn't break out here - } - - // same as while loop, but with a subtle difference. code is alway - // executed before the loop iteration expression is evaluate - // do..whiles are the least used looping structures - do { - index *= 2; - System.out.println( "index has value " + index ); - } while( index < 9999 ); - } -} diff --git a/java/_Basics/WordCount (Java).java b/java/_Basics/WordCount (Java).java deleted file mode 100644 index eb37900..0000000 --- a/java/_Basics/WordCount (Java).java +++ /dev/null @@ -1,194 +0,0 @@ -//Program that compares counting words in files using an ArrayList and a Map. - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Scanner; - -import javax.swing.JFileChooser; -import javax.swing.UIManager; - - -public class WordCount -{ - - public static void main(String[] args) - { - countWordsViaGUI(); - } - - - // allow user to pick file to exam via GUI. - // allow multiple picks - public static void countWordsViaGUI() - { - setLookAndFeel(); - try - { - Scanner key = new Scanner(System.in); - do - { - System.out.println("Opening GUI to choose file."); - Scanner fileScanner = new Scanner(getFile()); - Stopwatch st = new Stopwatch(); - st.start(); - ArrayList words = countWordsWithArrayList(fileScanner); - st.stop(); - System.out.println("time to count: " + st); - System.out.print("Enter number of words to display: "); - int numWordsToShow = Integer.parseInt(key.nextLine()); - showWords(words, numWordsToShow); - fileScanner.close(); - System.out.print("Perform another count? "); - } - while(key.nextLine().toLowerCase().charAt(0) == 'y'); - key.close(); - } - catch(FileNotFoundException e) - { - System.out.println("Problem reading the data file. Exiting the program." + e); - } - } - - - // determine distinct words in a file using an array list - private static ArrayList countWordsWithArrayList(Scanner fileScanner) - { - System.out.println("Total number of words: " + numWords); - System.out.println("number of distincy words: " + result.size()); - return result; - } - - - // determine distinct words in a file and frequency of each word with a Map - private static Map countWordsWithMap(Scanner fileScanner) - { - System.out.println("Total number of words: " + numWords); - System.out.println("number of distincy words: " + result.size()); - return result; - } - - - private static void showWords(ArrayList words, int numWordsToShow) - { - for(int i = 0; i < words.size() && i < numWordsToShow; i++) - System.out.println(words.get(i)); - } - - - private static void showWords(Map words, int numWordsToShow) - { - } - - - // perform a series of experiments on files. Determine average time to - // count words in files of various sizes - private static void performExp() - { - String[] smallerWorks = {"smallWords.txt", "2BR02B.txt", "Alice.txt", "SherlockHolmes.txt"};; - String[] bigFile = {"ciaFactBook2008.txt"}; - timingExpWithArrayList(smallerWorks, 50); - timingExpWithArrayList(bigFile, 3); - timingExpWithMap(smallerWorks, 50); - timingExpWithMap(bigFile, 3); - } - - - // pre: titles != null, elements of titles refer to files in the - // same path as this program, numExp >= 0 - // read words from files and print average time to cound words. - private static void timingExpWithMap(String[] titles, int numExp) - { - try - { - double[] times = new double[titles.length]; - final int NUM_EXP = 50; - for(int i = 0; i < NUM_EXP; i++) - { - for(int j = 0; j < titles.length; j++) - { - Scanner fileScanner = new Scanner(new File(titles[j])); - Stopwatch st = new Stopwatch(); - st.start(); - Map words = countWordsWithMap(fileScanner); - st.stop(); - System.out.println(words.size()); - times[j] += st.time(); - fileScanner.close(); - } - } - for(double a : times) - System.out.println(a / NUM_EXP); - } - catch(FileNotFoundException e) - { - System.out.println("Problem reading the data file. Exiting the program." + e); - } - } - - - // pre: titles != null, elements of titles refer to files in the - // same path as this program, numExp >= 0 - // read words from files and print average time to cound words. - private static void timingExpWithArrayList(String[] titles, int numExp) - { - try - { - double[] times = new double[titles.length]; - for(int i = 0; i < numExp; i++) - { - for(int j = 0; j < titles.length; j++) - { - Scanner fileScanner = new Scanner(new File(titles[j])); - Stopwatch st = new Stopwatch(); - st.start(); - ArrayList words = countWordsWithArrayList(fileScanner); - st.stop(); - times[j] += st.time(); - fileScanner.close(); - } - } - for(int i = 0; i < titles.length; i++) - System.out.println("Average time for " + titles[i] + ": " + (times[i] / numExp)); - } - catch(FileNotFoundException e) - { - System.out.println("Problem reading the data file. Exiting the program." + e); - } - } - - - // try to set look and feel to same as system - private static void setLookAndFeel() - { - try - { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } - catch(Exception e) - { - System.out.println("Unable to set look at feel to local settings. " + - "Continuing with default Java look and feel."); - } - } - - - /** Method to choose a file using a window. - * @return the file chosen by the user. Returns null if no file picked. - */ - private static File getFile() - { - // create a GUI window to pick the text to evaluate - JFileChooser chooser = new JFileChooser("."); - chooser.setDialogTitle("Select File To Count Words:"); - int retval = chooser.showOpenDialog(null); - File f =null; - chooser.grabFocus(); - if (retval == JFileChooser.APPROVE_OPTION) - f = chooser.getSelectedFile(); - return f; - } -} diff --git a/java/_Basics/Working with static class members.java b/java/_Basics/Working with static class members.java deleted file mode 100644 index fd02612..0000000 --- a/java/_Basics/Working with static class members.java +++ /dev/null @@ -1,29 +0,0 @@ -Working with static class members - - - - - -public class WorkingWithStaticClassMembers { - public static void main( String[] args ) { - Colour background = Colour.a; - } -} - -class Colour { - // take this slowly, you are defining constant class level - // objects for objects of this class - at compile time! boy i like Java! - public static final Colour a = new Colour( 255, 255, 255 ); - public static final Colour b = new Colour( 255, 255, 0 ); - public static final Colour c = new Colour( 255, 0, 0 ); - - private int red; - private int green; - private int blue; - - public Colour( int red, int green, int blue ) { - this.red = red; - this.green = green; - this.blue = blue; - } -} diff --git a/java/_Basics/Write a program to remove duplicates from sorted array.java b/java/_Basics/Write a program to remove duplicates from sorted array.java deleted file mode 100644 index 89862c0..0000000 --- a/java/_Basics/Write a program to remove duplicates from sorted array.java +++ /dev/null @@ -1,33 +0,0 @@ - package com.scanftree.algos; - public class MyDuplicateElements { - public static int[] removeDuplicates(int[] input) { - int j = 0; - int i = 1; - //return if the array length is less than 2 - if(input.length < 2) { - return input; - } - while(i < input.length) { - if(input[i] == input[j]) { - i++; - } else { - input[++j] = input[i++]; - } - } - int[] output = new int[j+1]; - for (int k=0; k25) -{ -cmas.setFullYear(cmas.getFullYear()+1); -} -var one_day=1000*60*60*24; -console.log(Math.ceil((cmas.getTime()-today.getTime())/(one_day))+ -" days left until Christmas!"); \ No newline at end of file diff --git a/js/_Basic/Write a JavaScript program to convert temperatures to and from celsius, fahrenheit..js b/js/_Basic/Write a JavaScript program to convert temperatures to and from celsius, fahrenheit..js deleted file mode 100644 index 784a3a3..0000000 --- a/js/_Basic/Write a JavaScript program to convert temperatures to and from celsius, fahrenheit..js +++ /dev/null @@ -1,17 +0,0 @@ -function cToF(celsius) -{ - var cTemp = celsius; - var cToFahr = cTemp * 9 / 5 + 32; - var message = cTemp+'\xB0C is ' + cToFahr + ' \xB0F.'; - console.log(message); -} - -function fToC(fahrenheit) -{ - var fTemp = fahrenheit; - var fToCel = (fTemp - 32) * 5 / 9; - var message = fTemp+'\xB0F is ' + fToCel + '\xB0C.'; - console.log(message); -} -cToF(60); -fToC(45); \ No newline at end of file diff --git a/js/_Basic/Write a JavaScript program to determine whether a given year is a leap year in the Gregorian calendar..js b/js/_Basic/Write a JavaScript program to determine whether a given year is a leap year in the Gregorian calendar..js deleted file mode 100644 index 8f9dd7a..0000000 --- a/js/_Basic/Write a JavaScript program to determine whether a given year is a leap year in the Gregorian calendar..js +++ /dev/null @@ -1,3 +0,0 @@ -year = window.prompt("Input a Year : "); -x = (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0); -alert(x); \ No newline at end of file diff --git a/js/_Basic/Write a JavaScript program to display the current day and time in the following format..js b/js/_Basic/Write a JavaScript program to display the current day and time in the following format..js deleted file mode 100644 index 4756ffa..0000000 --- a/js/_Basic/Write a JavaScript program to display the current day and time in the following format..js +++ /dev/null @@ -1,38 +0,0 @@ -var today = new Date(); -var day = today.getDay(); -var daylist = ["Sunday","Monday","Tuesday","Wednesday ","Thursday","Friday","Saturday"]; -console.log("Today is : " + daylist[day] + "."); -var hour = today.getHours(); -var minute = today.getMinutes(); -var second = today.getSeconds(); -var prepand = (hour >= 12)? " PM ":" AM "; -hour = (hour >= 12)? hour - 12: hour; - -if (hour===0 && prepand===' PM ') -{ - -if (minute===0 && second===0) -{ -hour=12; -prepand=' Noon'; -} -else -{ -hour=12; -prepand=' PM'; -} -} -if (hour===0 && prepand===' AM ') -{ -if (minute===0 && second===0) -{ -hour=12; -prepand=' Midnight'; -} -else -{ -hour=12; -prepand=' AM'; -} -} -console.log("Current Time : "+hour + prepand + " : " + minute + " : " + second); \ No newline at end of file diff --git a/js/_Basic/Write a JavaScript program to find which 1st January is being a Sunday between 2014 and 2050..js b/js/_Basic/Write a JavaScript program to find which 1st January is being a Sunday between 2014 and 2050..js deleted file mode 100644 index 2f56a30..0000000 --- a/js/_Basic/Write a JavaScript program to find which 1st January is being a Sunday between 2014 and 2050..js +++ /dev/null @@ -1,8 +0,0 @@ -console.log('--------------------'); -for (var year = 2014; year <= 2050; year++) - { - var d = new Date(year, 0, 1); - if ( d.getDay() === 0 ) - console.log("1st January is being a Sunday "+year); - } -console.log('--------------------'); \ No newline at end of file diff --git a/js/_Basic/Write a JavaScript program to get the current date..js b/js/_Basic/Write a JavaScript program to get the current date..js deleted file mode 100644 index 4200b38..0000000 --- a/js/_Basic/Write a JavaScript program to get the current date..js +++ /dev/null @@ -1,22 +0,0 @@ -var today = new Date(); -var dd = today.getDate(); - -var mm = today.getMonth()+1; -var yyyy = today.getFullYear(); -if(dd<10) -{ - dd='0'+dd; -} - -if(mm<10) -{ - mm='0'+mm; -} -today = mm+'-'+dd+'-'+yyyy; -console.log(today); -today = mm+'/'+dd+'/'+yyyy; -console.log(today); -today = dd+'-'+mm+'-'+yyyy; -console.log(today); -today = dd+'/'+mm+'/'+yyyy; -console.log(today); \ No newline at end of file diff --git a/js/_Basic/Write a JavaScript program to get the website URL (loading page)..js b/js/_Basic/Write a JavaScript program to get the website URL (loading page)..js deleted file mode 100644 index 8144450..0000000 --- a/js/_Basic/Write a JavaScript program to get the website URL (loading page)..js +++ /dev/null @@ -1,2 +0,0 @@ -//Write a JavaScript program to get the website URL (loading page) -alert(document.URL); \ No newline at end of file diff --git a/js/_Basic/Write a JavaScript program where the program takes a random integer between 1 to 10, the user is then prompted to input a guess number..js b/js/_Basic/Write a JavaScript program where the program takes a random integer between 1 to 10, the user is then prompted to input a guess number..js deleted file mode 100644 index f231585..0000000 --- a/js/_Basic/Write a JavaScript program where the program takes a random integer between 1 to 10, the user is then prompted to input a guess number..js +++ /dev/null @@ -1,7 +0,0 @@ -// Get a random integer from 1 to 10 inclusive - var num = Math.ceil(Math.random() * 10); - var gnum = prompt('Guess the number between 1 and 10 inclusive'); - if (gnum == num) - alert('Matched'); - else - alert('Not matched, the number was ' + num); \ No newline at end of file