[SOLVED] Geek Even and Old Answers to the Questions

Introduction:

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 “if a number is even or odd?”, “what is the factorial of a number?”, among other things. A Geek has a name and also keeps track of how many questions s/he has answered. Your Geek class must have only two instance variables – the Geek’s name and number of questions asked so far

Methods:


  1. public Geek (String name): the Geek's name, the number of questions is assigned to zero
  2. public String getName(): takes no parameters and returns the Geeks’s name as a String (don’t count this request in the total questions)
  3. public int getNumberOfQuestions(): takes no parameters and returns as an int how many questions has been asked (don’t count this request in the total)
  4. public boolean isEven (int num): takes an integer and returns a boolean value indicating if the num is even or not
  5. public boolean isVowel(char input): takes a character and returns true if the input character is a vowel (a, e, i, o or u). The method should be case-insensitive
  6. public int factorial(int num): takes an integer and computes the factorial of it. The factorial of a positive integer n (written n!) is equal to the product of the positive integers from 1 to n.
  7. public String printBinary(int num1): takes an integer as parameter and returns a string containing that integer’s binary representation. For example, the call of printBianry(44) should return 101100
  8. public int gcd(int num1, int num2): takes two integers and returns the greatest common divisor (GCD) of the two numbers. The GCD of two integers a and b is the largest integer that is a factor of both num1 and num2.
  9. Save the Geek class in a file called Geek.java and use the following program stored in Assignment5.java, which has the main method to create new Geek object and to test the methods in the class Geek. A sample output is shown below
  10. Important Notes: Your class should have exactly the method headers that are described or otherwise your class will not work with the test driver program (Assignment5.java) that is provided. You should never change the test driver program if the test driver is provided but instead make changes to Geek class to make it work.
  11. Assignment5.java will ask a user to enter one of the following commands. Based on the user's choice, the program needs to perform corresponding operation. This will be done by using a method you defined in the Geek class. The program will terminate when the user enters 'q'. Here is a sample output:

Command Options
-----------------------------------
a: get name
b: number of questions asked
c: is even
d: is it a vowel
e: factorial
f: print Binary
g: find GCD
?: display the menu again

Get your solution now 

Buy now

Comments

Popular posts from this blog

[SOLVED] Tape for a Turing Machine using Doubly-linked List in Java with full source code

[SOLVED] Branch Coverage, Statement Coverage and Path Coverage | Java Unit Testing

[SOLVED] Buggy Search And Sort Buy Reporting with Java source code