diff --git a/HelloGit/Source Files/HelloWorld.java b/HelloGit/Source Files/HelloWorld.java index 4ad8335..b0dd77d 100644 --- a/HelloGit/Source Files/HelloWorld.java +++ b/HelloGit/Source Files/HelloWorld.java @@ -2,7 +2,9 @@ public class HelloWorld { public static void main(String[] args) { - System.out.println("Helloworld"); + System.out.println("Hello Life Team test 2 swag!!!"); + System.out.println("Git testing yo momma!"); + } diff --git a/HelloGit/Source Files/mathBranch.java b/HelloGit/Source Files/mathBranch.java new file mode 100644 index 0000000..2d2f05f --- /dev/null +++ b/HelloGit/Source Files/mathBranch.java @@ -0,0 +1,101 @@ +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Scanner; + + +public class mathBranch { + //Mutator + public void setNumber(int num) + { + number = num; + } + + //Accessor + public int getNumber() + { + return number; + } + + //Receives user input + public void askForNumber() + { + System.out.print("What number wouldyou like to use?"); + this.setNumber(userInput.nextInt()); + } + + //Splits the numbers into separate digits and assigns them + //to the private list then the list is reversed for display purposes + public void dissect(int num,List spList) + { + while(num > 0) + { + spList.add(num%10); + num = num/10; + } + Collections.reverse(spList); + System.out.println (spList); + } + + //Raises all elements within a list to the power of 2 + public void squareNumbers(List splitNum) + { + int k; + + for( k = 0; k < splitNum.size(); k++) + { + splitNum.set(k, (int)((Math.pow(splitNum.get(k), 2)))); + } + } + + //Returns the sum of all the elements within the list + public int sum(List sumNum) + { + int k,sum; + sum = 0; + + for( k = 0; k < sumNum.size(); k++) + { + sum += sumNum.get(k); + } + return sum; + } + + //Recursive method to check if a number is happy + public void checkIfHappy(int numberToCheck) + { + int flag; + + this.dissect(numberToCheck,splitNumbers); + this.squareNumbers(splitNumbers); + flag = this.sum(splitNumbers); + + checkedNumbers.add(numberToCheck); + if (flag == 1) + { + System.out.println("Yes, your number is happy."); + } + //If the number has been checked before, it is not happy + else if(checkedNumbers.contains(flag)) + { + int flagIndex; + flagIndex = checkedNumbers.indexOf(flag); + System.out.println(checkedNumbers.get(flagIndex)); + System.out.println("No your number is not happy"); + } + //Repeat the process and clear the list + else + { + splitNumbers.clear(); + this.checkIfHappy(flag); + } + } + + //Private members, number given, empty list for the split digits, + //and an empty list to add the numbers that have been checked + private int number; + private List splitNumbers = new ArrayList(); + private List checkedNumbers = new ArrayList(); + Scanner userInput = new Scanner(System.in); + +} diff --git a/HelloGit/Source Files/moreMath.java b/HelloGit/Source Files/moreMath.java new file mode 100644 index 0000000..ba25d88 --- /dev/null +++ b/HelloGit/Source Files/moreMath.java @@ -0,0 +1,57 @@ + +public class moreMath { + //Loan term accessor multiplies the loan by 12 to account for the + //monthly payments + public int getLoanTerm() + { + return loanTerm*12; + } + + public double getTheMortgage() + { + return theMortgage; + } + + //Interest rate accessor divides by 100 to change the int given into + //a percentage and divides that number to account for the monthly payments + public double getInterestRate() + { + return ((interestRate/100)/12); + } + + //Mutators + public void setLoanTerm(int term) + { + loanTerm= term; + } + public void setTheMortgage(double loan) + { + theMortgage = loan; + } + public void setInterestRate(double interest) + { + interestRate = interest; + } + + //Method to calculate the monthly payments + public double calculateMonthlyPayments() + { + //instantiate local variables + double monthly; + double dividend; + double divisor; + + //assign dividend and divisor individually to help visually + dividend = this.getInterestRate()* + (Math.pow((1+this.getInterestRate()),(this.getLoanTerm()))); + divisor = Math.pow((1+this.getInterestRate()),(this.getLoanTerm()))-1; + monthly = this.getTheMortgage()*(dividend/divisor); + return monthly; + } + + //Private members of mortgageMath class + private int loanTerm ; + private double theMortgage ; + private double interestRate; + +}