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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.metadata/
/.recommenders/
6 changes: 6 additions & 0 deletions Calculator/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Calculator/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Calculator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions Calculator/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Binary file added Calculator/bin/Calculator.class
Binary file not shown.
39 changes: 39 additions & 0 deletions Calculator/src/Calculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import java.util.Scanner;

public class Calculator {
public static void main(String[] args) {

Scanner input = new Scanner(System.in);

// Get first number
System.out.println("Please enter the first number: ");
int num1 = input.nextInt();

// Get second number
System.out.println("Please enter the second number: ");
int num2 = input.nextInt();

// Add the numbers together
int add = num1 + num2;
// Print out sum
System.out.println("The sum of those numbers is: " +add);

// Subtract the second number from the first
int subtract = num1 - num2;
// Print out subtraction
System.out.println("The difference between those numbers is: " +subtract);

// Multiply the numbers
int multiply = num1 * num2;
// Print out multiplication
System.out.println("The product of those numbers is: " +multiply);

// Divide the numbers
int divide = num1 / num2;
// Print out quotient
System.out.println("The quotient of those numbers is: " +divide);

input.close();
}

}
6 changes: 6 additions & 0 deletions FunWithStrings/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions FunWithStrings/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions FunWithStrings/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FunWithStrings</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions FunWithStrings/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
9 changes: 9 additions & 0 deletions FunWithStrings/src/FunWithStrings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

public class FunWithStrings {

public static void main(String[] args) {
// TODO Auto-generated method stub

}

}
6 changes: 6 additions & 0 deletions GradeBook/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions GradeBook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions GradeBook/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GradeBook</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions GradeBook/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
79 changes: 79 additions & 0 deletions GradeBook/src/GradeBook.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashMap;

public class GradeBook {

//Create static String for the grades
static HashMap<String, String> gradeBook = new HashMap<String, String>();
static HashMap<String, Double> gradePointAverage = new HashMap<String, Double>();

// Obligatory main method
public static void main(String[] args) {

// Initialize the fields
inputGrades();
makeStringArray();
printGrades();
}

//Store the name + grades for each student
public static void inputGrades() {
Scanner reader = new Scanner(System.in);
System.out.println("How many students will be added to the grade book?");
Integer numberOfStudents = reader.nextInt();
reader.nextLine();
for (int i=0; i<numberOfStudents; i++) {

System.out.println("What is the student's name?");
String name = reader.nextLine();
System.out.println("What are " + (name) + "\'s grades separated by a comma?");
String grades = reader.nextLine();

// Add each student's name and grades to HashMap
gradeBook.put(name, grades);
}
reader.close();
}

//Create array of strings out of hash map using the name as the key and the grades as the values
public static void makeStringArray() {
String[] listOfStudents = (String[]) gradeBook.keySet().toArray(new String[0]);
String[] listOfFinalGrades = (String[]) gradeBook.values().toArray(new String[0]);

//Split each student's grades into separate strings and then convert all into an array of strings
for(int i=0; i<listOfFinalGrades.length; i++) {
String grades = listOfFinalGrades[i];
String[] stringArray = grades.split(",");

//convert array of strings into array of integers
Integer[] intArray = new Integer[stringArray.length];
for (int j = 0; j < intArray.length; j++) {
Integer num = Integer.parseInt(stringArray[j]);
intArray[j] = num;
}

//Figure out the grade point average
double sum = 0;
for (int k=0;k<intArray.length;k++) {
sum = sum + intArray[k];
}
double average = sum / intArray.length;
gradePointAverage.put(listOfStudents[i], average);
}

}

public static void printGrades() {
String[] listOfStudents = (String[]) gradePointAverage.keySet().toArray(new String[0]);
Double[] listOfAverages = (Double[]) gradePointAverage.values().toArray(new Double[0]);

for (int i = 0; i < listOfStudents.length; i++) {
String currentName = listOfStudents[i];
double currentAvg = listOfAverages[i];

System.out.println(currentName + "'s grade point average is " + currentAvg);
}
}

}
6 changes: 6 additions & 0 deletions PigLatin/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions PigLatin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions PigLatin/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PigLatin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions PigLatin/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
57 changes: 57 additions & 0 deletions PigLatin/src/PigLatin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import java.util.Scanner;

public class PigLatin {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

// Ask user for a word
System.out.println("Enter a word to translate it into Pig Latin.");

// This variable holds the word the user inputs and converts it to a string
String userWord = scan.next();

// Let's ensure legibility by converting the user's input into lower case
userWord = userWord.toLowerCase();

// This is the variable that holds the user's word translated into Pig Latin
String translatedWord = "";

// Let's assume there are no vowels in userWord and set the value of int to 0
int flag = 0;

// Let's iterate through the string to find the first vowel as defined by x.
for (int i = 0; i < userWord.length(); i++) {
char x = userWord.charAt(i);
if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u') {
/*
* Make the translation by creating a substring of all the letters up to the
* first vowel moving these to the end of the original string, and appending
* 'ay' after that.
*/
translatedWord = userWord.substring(i) + userWord.substring(0, i) + "ay";

// Change flag to 1 to indicate userWord has been translated and break the loop.
flag = 1;
break;

}
}

/*
* if there are no vowels in userWord, flag remains 0 and the word isn't
* translated. To translate a vowel-less userWord, append 'ay' to the end.
*/
if (flag == 0) {
translatedWord = userWord + "ay";
}

// Show the user's word translated into Pig Latin
System.out.println("That word translated into Pig Latin is: " + translatedWord);

scan.close();

}

}
6 changes: 6 additions & 0 deletions RockPaperScissors/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions RockPaperScissors/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions RockPaperScissors/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RockPaperScissors</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions RockPaperScissors/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Loading