Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Geek {
- private String Name;
- private int NumberOfQuestions;
- public Geek(String name) {
- this.Name = name;
- this.NumberOfQuestions = 0;
- }
- public String getName() {
- return Name;
- }
- public int getNumberOfQuestions() {
- return NumberOfQuestions;
- }
- public boolean isEven(int num) {
- NumberOfQuestions++;
- if ((num % 2) == 0) {
- return true;
- } else {
- return false;
- }
- }
- public String multiConcat(String text, int count) {
- NumberOfQuestions++;
- if (count < 2) {
- return text;
- }
- String Textout = "";
- for (int i = 0; i < count; i++) {
- Textout = Textout.concat(text);
- }
- return Textout;
- }
- public int sumRange(int num1, int num2) {
- NumberOfQuestions++;
- if (num1 >= (num2 - 1)) {
- return 0;
- }
- int SumOfNumbers = 0;
- for (int i = ((num2 - 1) - num1); i > 0; i--) {
- SumOfNumbers = +num1 + i;
- }
- return SumOfNumbers;
- }
- public boolean sorted(int num1, int num2, int num3) {
- NumberOfQuestions++;
- if (num2 < num1) {
- return false;
- }
- if (num3 < num2) {
- return false;
- }
- return true;
- }
- public int countA(String text) {
- NumberOfQuestions++;
- int NumberOfA = 0;
- String LowerText = text.toLowerCase();
- for (int i = 0; i < text.length(); i++) {
- if ((LowerText.charAt(i)) == 'a') {
- NumberOfA++;
- }
- }
- return NumberOfA;
- }
- public int countDigits(int num) {
- NumberOfQuestions++;
- int length = 0;
- String Numbers = "";
- Numbers = Integer.toString(num);
- length = Numbers.length();
- return length;
- }
- public boolean isPrime(int num) {
- NumberOfQuestions++;
- if(num<=1) {
- return false;
- }
- for (int x = 2; x < num; x++) { // while 2 is less than num, increment
- if ((num % x) == 0) {// if the modulo of num and x is 0 set prime to false
- return false;
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement