Skip to main content

[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

The Zoo Management System - entity relationship diagram & MS Access Database

Zoo Management System - Project Details: You are the employee of a big, worldwide working Zoo Management Company. Your company is responsible for the Zoo management. Your boss thinks it would be a great idea to store all data for each Zoo in a brand new self-developed ZOO Management System. Up to now, the ZOO management company has maps of each ZOO available. Your boss knows that you took a course in introduction on an ERP system, so he asks you if you could help designing such a system. Each ZOO must have the same organizational structure, which should look like this: Each Zoo has a Zoo-Address. Each Zoo has many visitors (Visitor Ticket Process (VTP). Many Zoo-Attractions belong to a Zoo. Module 1: Entity Relationship Diagram Design a ER (entity-relationship) diagram for your ZOO Management System. Use the information provided below with the entities and its attributes. Put the entities in the correct relationship to each other (organizational structure). Module 2: DB Implem...

EIT Knowledge and Innovative Community Scholarships has been announced

Admission Criteria To qualify for our programmes, applicants need to fulfill the admission requirements based on previous studies, English proficiency and relevant documentation. Previous Studies: A Completed Bachelor’s Degree In order to be admitted into a KIC InnoEnergy MSc programme, you must have completed a Bachelor’s degree encompassing a minimum of 180 ECTS credits or equivalent academic qualifications from an internationally recognized university. Please note that admissions depend on the specific BSc degree you hold for entry into the MSc programme you are interested in. Conditional Acceptance – Undergraduate Students in Final Year Students in their final year of undergraduate education may also apply and if expected to qualify, receive a conditional offer. If you have not completed your studies, please include a written statement from your university’s administration office (or equivalent department), confirming that you are enrolled in the final year of your study programme ...

Human Physiology by Stuart Ira Fox [PDF] (12th edition) free download