edumeister_logo

public class Geek {private String name;private intshowing page 1 out of 1

public class Geek {
private String name;
private int numberOfQuestions;
public Geek(String newName, int numQuestions) {
name = newName;
numberOfQuestions = numQuestions;
}
public String getName() {
return name;
}
public int getNumberOfQuestions() {
return numberOfQuestions;
}
public boolean isEven(int num1, int num2) {
numberOfQuestions++;
boolean result =
(num1+num2)%2 == 0;
return result;
}
public double sum(double num1, double num2) {
numberOfQuestions++;
double sum = 0;
if (num2 > num1)
sum = (num1 + num2)/2 * (num2-num1 + 1);
else if (num1 > num2)
sum = (num1 + num2)/2 * (num1-num2 + 1);
else if (num1 == num2)
sum = num1;
return sum;
}
public boolean leapYear(int year) {
numberOfQuestions++;
boolean result =
((year % 4 == 0) && (year % 100 !=0) && (year >=
1582)) || ((year % 400 == 0) && (year >= 1582));
return result;
}
}