public class MethodParams {
public static void main(String[] args) {
MethodParams mp = new MethodParams();
double theNum = mp.convertIntToDouble(44);
System.out.println(theNum);
System.out.println(mp.sum(1.0, 2, 3));
}
public double convertIntToDouble(int num){
return (double)num;
}
public double sum(double num1, int num2, int num3){
return num1 + num2 + num3;
}
public double[] square(int float1, int float2, int float3, int float4) {
double[] fluffier = {float1*float1, float2*float2, float3*float3 + float4*float4};
return fluffier;
}
public String findFirstWord(String a, String b) {
//convert Strings to array for iterating over
char[] aArray = a.toCharArray();
char[] bArray = b.toCharArray();
//loop through letters of each
for (int i = 0; i < aArray.length; i++) {
//if letter in a comes before b, then return a
if (aArray[i] < bArray[i]) {
return a;
}
//check if letter in b comes before a
if (aArray[i] > bArray[i]) {
return b;
}
//otherwise they are equal and you can move to the next letter
}
//you need this line in case the above loop doesn't return anything.
//this is for the compiler.
return a;
}
}