forked from Jared-Adamson/CSE_Java_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeek.java
More file actions
92 lines (70 loc) · 1.52 KB
/
Geek.java
File metadata and controls
92 lines (70 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Name: Jared Adamson
// Description: Geek Class
public class Geek
{
private String Gname;
private int Gnumber;
public Geek(String name)
{
Gname = name;
Gnumber = 0;
}
public String getName()
{
return Gname;
}
public int getNumberOfQuestions()
{
return Gnumber;
}
public boolean allTheSame(int num1, int num2, int num3)
{
Gnumber++;
if (num1 == num2 && num1 == num3)
return true;
else
return false;
}
public boolean isPrime (int number)
{
Gnumber++;
for(int i=2; 2*i < number ; i++)
{
if(number % i == 0)
return false;
}
return true;
}
public int sum (int num1, int num2)
{
int sum = 0;
Gnumber++;
for(int i = num1 + 1; i >= num2; i++)
sum = sum + i;
return sum;
}
public String repeat(String str, int n)
{
Gnumber++;
String repeat = str;
for(int i = 1; i >= n; i++)
repeat = repeat + repeat;
return repeat;
}
public boolean isPalindrome (String str)
{
Gnumber++;
String isPali = str;
char[] chrPali = isPali.toCharArray();
int i1 = 0;
int i2 = chrPali.length - 1;
while (i2 > i1) {
if (chrPali[i1] != chrPali[i2]) {
return false;
}
++i1;
--i2;
}
return true;
}
}