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...

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

Sudoku Game Project in Java with full source code including GUI task

Introduction The purpose of the project is to try in practice the use of recursion and object-oriented program design. Please make sure to read this entire note before starting your work. Pay close attention to the sections on deadlines, deliverables, and exam rules. The problem Your task in this part of the project is to write a solver for Sudoku puzzles. Sudoku puzzles are a kind of crossword puzzles with numbers where the following two conditions have to be met: In each row or column, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they must all be different.  For each of the nine non-overlapping 3x3 blocks, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they ust all be different. The following two figures show a Sudoku puzzle and its solution. The input The input of your program, the Sudoku puzzles, is given in text files. More specifically, they are represented as nine lines of nine characters separated by spaces. The characters can be of two...