Skip to content
4 changes: 3 additions & 1 deletion HelloGit/Source Files/HelloWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -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!");


}

Expand Down
101 changes: 101 additions & 0 deletions HelloGit/Source Files/mathBranch.java
Original file line number Diff line number Diff line change
@@ -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<Integer> 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<Integer> 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<Integer> 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<Integer> splitNumbers = new ArrayList<Integer>();
private List<Integer> checkedNumbers = new ArrayList<Integer>();
Scanner userInput = new Scanner(System.in);

}
57 changes: 57 additions & 0 deletions HelloGit/Source Files/moreMath.java
Original file line number Diff line number Diff line change
@@ -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;

}