Skip to content

Commit 2946647

Browse files
committed
initial work
1 parent 195581d commit 2946647

32 files changed

+1143
-38
lines changed

.gitignore

-35
This file was deleted.

README.md

+294-3
Large diffs are not rendered by default.

java/.classpath

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

java/.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>JavaMegaProjectList</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

java/bin/projects/CountWords.class

1.54 KB
Binary file not shown.

java/bin/projects/CoutVowels.class

1.08 KB
Binary file not shown.
1.57 KB
Binary file not shown.

java/bin/projects/PigLatin.class

1.73 KB
Binary file not shown.

java/bin/projects/ReverseString.class

1.09 KB
Binary file not shown.

java/bin/projects/TextEditor.class

110 Bytes
Binary file not shown.

java/src/projects/CountWords.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package projects;
2+
3+
import java.io.File;
4+
import java.io.FileNotFoundException;
5+
import java.util.Scanner;
6+
7+
public class CountWords {
8+
public static void main(String[] args) {
9+
CountWords("This is a sentence with 7 words");
10+
CountWords("po op");
11+
12+
CountWordsFromFile("src/projects/paragraph.txt");
13+
}
14+
private static void CountWords(String inputString) {
15+
System.out.println(inputString.split(" ").length + " words in the analyzed text");
16+
}
17+
private static void CountWordsFromFile(String filePath) {
18+
try {
19+
String text = new Scanner( new File(filePath) ).useDelimiter("\\A").next();
20+
CountWords(text);
21+
} catch (FileNotFoundException e) {
22+
e.printStackTrace();
23+
}
24+
}
25+
}

java/src/projects/CoutVowels.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package projects;
2+
3+
public class CoutVowels {
4+
public static void main(String[] args) {
5+
CountVowels("This is a sentence with vowels");
6+
CountVowels("There are 6 vowels");
7+
}
8+
private static void CountVowels(String inputString) {
9+
char[] vowels = {'a', 'e', 'i', 'o', 'u'};
10+
int vowelCount = 0;
11+
for (char inputCh: inputString.toCharArray()) {
12+
for(char vowel: vowels){
13+
if(inputCh == vowel){
14+
vowelCount++;
15+
}
16+
}
17+
}
18+
System.out.println(vowelCount);
19+
}
20+
}
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package projects;
2+
3+
public class PalindromeCheck {
4+
public static void main(String[] args) {
5+
PalindromeCheck("racecar");
6+
PalindromeCheck("poop");
7+
}
8+
private static void PalindromeCheck(String inputString) {
9+
if (inputString.length() % 2 == 0) {
10+
// even
11+
int num = inputString.length()-1;
12+
String firstHalf = inputString.substring(0, inputString.length() / 2);
13+
String secondHalf = "";
14+
while(num >= inputString.length() / 2){
15+
secondHalf += inputString.charAt(num);
16+
num--;
17+
}
18+
System.out.println("Is " + inputString + " a palindrome? " + firstHalf.equals(secondHalf));
19+
//System.out.println(firstHalf + " = " + secondHalf);
20+
} else {
21+
// odd
22+
int num = inputString.length()-1;
23+
String firstHalf = inputString.substring(0, inputString.length() / 2);
24+
String secondHalf = "";
25+
while(num >= inputString.length() / 2 +1){
26+
secondHalf += inputString.charAt(num);
27+
num--;
28+
}
29+
System.out.println("Is " + inputString + " a palindrome? " + firstHalf.equals(secondHalf));
30+
//System.out.println(firstHalf + " = " + secondHalf);
31+
}
32+
}
33+
}

java/src/projects/PigLatin.java

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package projects;
2+
3+
public class PigLatin {
4+
public static void main(String[] args) {
5+
PigLatin("Banana");
6+
PigLatin("example");
7+
}
8+
private static void PigLatin(String inputString) {
9+
char[] consonants = {'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'};
10+
char firstChar = inputString.toLowerCase().charAt(0);
11+
String pigLatin = "";
12+
Boolean consonantFirst = false;
13+
for (char consonant : consonants) {
14+
if(firstChar == consonant){
15+
pigLatin = inputString.replaceFirst(String.valueOf(inputString.charAt(0)), "") + consonant + "ay";
16+
System.out.println(pigLatin);
17+
consonantFirst = true;
18+
break;
19+
}
20+
}
21+
if(consonantFirst == false){
22+
pigLatin = inputString + "way";
23+
System.out.println(pigLatin);
24+
}
25+
}
26+
}

java/src/projects/ReverseString.java

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package projects;
2+
3+
public class ReverseString {
4+
public static void main(String[] args) {
5+
ReverseString("meow");
6+
}
7+
private static void ReverseString(String inputString) {
8+
String reverseString = "";
9+
int num = inputString.length() - 1;
10+
for(int i = 0; i < inputString.length(); i++) {
11+
reverseString += inputString.charAt(num);
12+
num--;
13+
}
14+
System.out.println(reverseString);
15+
}
16+
}

java/src/projects/TextEditor.java

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package projects;
2+
3+
public interface TextEditor {
4+
5+
}

java/src/projects/paragraph.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer id tellus neque. Aliquam sit amet tempus tellus. Sed ac nisi diam. Sed sit amet ultricies nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis molestie sapien fringilla lacus luctus, sed aliquam risus scelerisque. Mauris interdum risus et elementum vehicula. In at fermentum nibh, ut blandit ligula. Nullam ultricies ultrices arcu, sed aliquam nisl lobortis sed.
2+
3+
73 words

python/count_vowels.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def count_vowels(string):
2+
vowels = ['a', 'e', 'i', 'o', 'u']
3+
lower_string = string.lower()
4+
vowel_count = 0
5+
for char in string:
6+
for vowel in vowels:
7+
if char == vowel:
8+
vowel_count+=1
9+
return vowel_count
10+
11+
print count_vowels("This is a sentence with vowels")
12+
print count_vowels("There are 6 vowels")

python/count_words.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def count_words(text):
2+
return str(len(text.split(" "))) + " words in the analyzed text"
3+
4+
def count_from_file(file_location):
5+
file = open(file_location, 'r')
6+
text = str(file.read())
7+
return count_words(text)
8+
9+
print count_words("This is a sentence with 7 words")
10+
print count_from_file("paragraph.txt")

python/palindrome.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#import reverse_string
2+
def palindrome(string):
3+
num = len(string) - 1
4+
second_half = ''
5+
mid = len(string) - 1
6+
while (num > mid/2):
7+
second_half += string[num]
8+
num -=1
9+
10+
first_half = string[:len(string)/2]
11+
if first_half == second_half:
12+
return True
13+
else:
14+
return False
15+
16+
print palindrome("racecar")
17+
print palindrome("poop")

python/paragraph.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer id tellus neque. Aliquam sit amet tempus tellus. Sed ac nisi diam. Sed sit amet ultricies nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis molestie sapien fringilla lacus luctus, sed aliquam risus scelerisque. Mauris interdum risus et elementum vehicula. In at fermentum nibh, ut blandit ligula. Nullam ultricies ultrices arcu, sed aliquam nisl lobortis sed.
2+
3+
73 words

python/pig_latin.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def pig_latin(string):
2+
string = string.lower()
3+
consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z']
4+
first_letter = string[0]
5+
pig_latin = ''
6+
for consonant in consonants:
7+
if first_letter == consonant:
8+
pig_latin = string.split(consonant, 1)[1] + first_letter +"ay"
9+
return pig_latin
10+
else:
11+
pig_latin = string + "way"
12+
return pig_latin
13+
14+
print pig_latin("Banana")
15+
print pig_latin("example")

python/pig_latin.pyc

1.13 KB
Binary file not shown.

python/reverse_string.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def reverse_string(string):
2+
reverse_string = ''
3+
num = len(string) - 1
4+
for i in string:
5+
reverse_string += string[num]
6+
num-=1
7+
return reverse_string
8+
9+
print reverse_string("Example String")

python/reverse_string.pyc

477 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)