Question
For this assignment, you will implement a class named Geek in a file named Geek.java . For our purposes, a geek is someone who delights
For this assignment, you will implement a class named Geek in a file named Geek.java. For our purposes, a geek is someone who delights in answering all sorts of questions, such as:
- Is the number 381 evenly divisible by 3?
- Which of these numbers is closes to Pi, 2.91 or 3.29?
- How many times does the letter 'a' appear in the statement "an apple a day keeps the doctor away."?
- Is the number 7 between the numbers 9 and 6?
- What number do you get if you reverse the digits of the number 38714?
In addition to being able to answer questions like these, a Geek will keep track of their name and the number of questions he or she has been asked.
you are given the following driver file named Assignment5.java. This file contains a main method and some supporting methods. This driver file will be used to test the Geek class that you implement. Make no changes to this driver file.
Your Geek class must have only two instance variables one for the Geeks name and one for the numberOfQuestions asked so far.
Sample run 1:
Command Options ----------------------------------- a) Display Geek's name b) Display Number of questions asked so far c) Is number evenly divisible by 3 d) Which of two numbers is closer to Pi e) Count number of times a letter appears in a string f) Is number between two other numbers g) Reverse a number ?) Display this menu q) Quit Please enter a command: a Geek's name: Bob Smith Please enter a command: b Number of questions asked so far: 0 Please enter a command: c Enter an integer: 123 123 is evenly divisible by 3 Please enter a command: c Enter an integer: 124 124 is not evenly divisible by 3 Please enter a command: d Enter the first number: 1.11 Enter the second number: 9.99 1.11 is closer to Pi Please enter a command: e Enter a statement: over the river, and through the wood Enter a letter to search for: o o appears 4 times Please enter a command: f Enter three integers: 1 2 3 2 is between 1 and 3 Please enter a command: f Enter three integers: 1 5 3 5 is not between 1 and 3 Please enter a command: g Enter an integer: 123456 The digits in reverse are 654321 Please enter a command: ? Command Options ----------------------------------- a) Display Geek's name b) Display Number of questions asked so far c) Is number evenly divisible by 3 d) Which of two numbers is closer to Pi e) Count number of times a letter appears in a string f) Is number between two other numbers g) Reverse a number ?) Display this menu q) Quit Please enter a command: qTranscribed image text
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started