Write a class definition (not a program, there is no main method) named Geek (saved in a file Geek.java) that models a person who is a geek. For our purposes, a geek is someone who delights in answering all sorts of questions, such as what is the sum of all numbers between two numbers?, If a number is even?, and etc. A Geek has a name and also keeps track of how many questions s/he has answered.
Your Geek class must have:
Save the Geek class in a file called Geek.java and Assignment5.java in the same folder. Assignment5.java is a test driver code for the Geek class.
Assignment5.java will ask a user to enter one of the following commands. Based on the user's choice, the program performs corresponding operation. This will be done by calling (invoking) one of the methods you defined in the Geek class. The program will terminate when the user enters 'q'.
Command Options
-----------------------------------
a: Get name
b: Num of questions asked
c: Is it Even
d: All the same
e: Sum between two integers
f: Repeat
g: Number of Digits
h: Middle of String
?: Display
q: Quit
Here is the description for each option:
a: asks for the Geek's name
b: returns the number of questions asked so far
c: asks for two integers and returns Boolean indicating if the sum is even or odd
d: asks for three positive integers and returns true if they are the same, false otherwise
e: asks for two integers and returns the sum between two integers
f: asks for a string and repeats count number of times
g. asks for an integer and counts how many digits it has
h: returns the middle character of a string if is odd, 2 characters if it is even
?: displays the menu
q: quits
Helpful hints for doing this assignment:
Sample Output (user input is in RED):
Command Options
-----------------------------------
a: Get name
b: Num of questions asked
c: Is it Even
d: All the same
e: Sum between two integers
f: Repeat
g: Number of Digits
h: Middle of String
?: Display
q: Quit
Please enter a command or type ?
a
Eisenstein
Please enter a command or type ?
b
0
Please enter a command or type ?
c
Enter two numbers: 4 5
Sum is not even
Please enter a command or type ?
f
Enter a string: hi How many times to repeat: 4
hihihihi
Please enter a command or type ?
g
Enter a number: 5
The number 5 has 1 digits
Please enter a command or type ?
g
Enter a number: 77854
The number 77854 has 5 digits
Please enter a command or type ?
h
Enter a string: java
The middle of string "java" is av
Please enter a command or type ?
h
Enter a string: hello
The middle of string "hello" is l
Please enter a command or type ?
b
6
Please enter a command or type ?
c
Enter two numbers: 4 5
Sum is not even
Please enter a command or type ?
d
Enter 3 integers: 4 5 6
All are NOT the same
Please enter a command or type ?
d
Enter 3 integers: 4 4 4
All the same!
Please enter a command or type ?
e
Enter the first number: 5
Enter the second number: 10
The sum between 5 and 10 is 45
Please enter a command or type ?
e
Enter the first number: 10
Enter the second number: 5
The sum between 10 and 5 is 45
Please enter a command or type ?
q
Press any key to continue . . .