Implement classes and testing

Assignment Help JAVA Programming
Reference no: EM131586266

Topics

- Implementing classes & testing

Coding Guidelines:
- Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc).
- Keep identifiers to a reasonably short length.
- User upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects).
- Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of spaces or tabs that you use to indent.
- Use white space to make your program more readable.

Part #1: Written Exercises (0 pts)
None

Part #2 - Programming (20 pts)
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 "is this string a palindrome?", "what is the sum of all numbers between two numbers?" 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.
- public Geek(String name, int numQuestions) - Constructor - sets the Geek's name and the num- ber of questions asked.
- public String getName() - Takes no parameters and returns the Geek's name as a String (don't count this request in the total questions).
- public int getNumberOfQuestions() - Takes no parameters and returns as an int how many ques- tions has been asked (don't count this request in the total).
- public boolean isEven(int num1, int num2) - It takes two integers and returns a boolean value indicating if the sum of the numbers is even or not (this counts as the Geek being asked one more question, so update the appropriate instance variable).

- public int sum(int num1, int num2) - Takes two integers and returns an int which is the sum of all numbers between the two inclusive (include the numbers in the sum) - for full credit this method should work even if the two numbers are the same (the sum is just one of the numbers) or if the first number is larger than the second. Also, you cannot assume which number will be greater.
- public boolean leapYear(int year) - It takes an integer and returns a boolean value indicating if the year is a leap year. A leap year is one with 366 days. A year is a leap year if:
- it is divisible by 4 (for example, 1980),
- except that it is not a leap year if it is divisible by 100 (for example 1900);
- however, it is a leap year if it is divisible by 400 (for example, 2000).
There were no exceptions before the introduction of the Gregorian calendar on October 15, 1582 (for example, 1500 was a leap year). You may NOT use Java's GregorianCalendar class. (This counts as the Geek being asked one more question, so update the appropriate instance variable).

Save the Geek class in a file called Geek.java. Write a test driver called Assignment5.java with the main method to create a new Geek object and to test the methods in the class Geek. A sample output is shown below.

Assignment5.java will provide the following menu to the user. Based on the user's choice, the program needs to perform 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: number of questions asked c: sum is even
d: sum between two integers e: leap year
?: display the menu again q: quit this program

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 prints if the sum of the numbers is even
d: asks for two integers and returns the sum of all numbers between them, inclusive e: asks for an integer and returns if it is a leap year or not
?: displays the menu q: quits

Reference no: EM131586266

Questions Cloud

Create an inheritance hierarchy : Create an Inheritance hierarchy that a bank may use to represent customers bank accounts - charges a fixed fee for each transaction the customer makes
Amount as in the previous question : Using the same mortgage amount as in the previous question how much higher or lower would be your monthly payment under a 15-year mortgage
Describe what sir robert peel implemented his nine principle : describe what Sir Robert Peel implemented his Nine Principles to give guidance to the newly formed New Westminster Police Service
Create a values conflict among stakeholders : In these situations, a conflict develops between the personal moral philosophy of the employees and the organization's goals or culture.
Implement classes and testing : CSE110 - 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
Yield to maturity rises : What is the percentage change in the price of this bond if the yield to maturity rises from 6.25% to 6.5%?
Describe yourself your career aspirations and expectations : Describe yourself, your career aspirations and expectations. Why are you seeking an MBA from the Koc University Graduate School of Business?
Data for testing the hypothesis : Analyze the most appropriate sample selection technique to gather data for testing the hypothesis.
Identify which performing culture best suits your philosophy : Identify which performing culture best suits your philosophy regarding change management and provide your rationale.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Building your own er model editor

Take user input from GUI and normalize the relationship between entities - important components of ER-model Editor - ER-Diagram Editor and code generator. This would involve building our own ER model editor that would allow user to add their own SQL..

  Write partial code using a loop to produces the given output

CSE 110- Write partial code using a loop to produces given output. Write a Java program called Assignment4.java. There are two tasks in this assignment. Your program will ask for user choice and based on which it will switch between the two tasks.

  Disadvantages to using data structures

How are data structures managed and organized in this language. How does the management or syntax of data structures in this language differ from how data structures are handled in other language.

  Define your own recursive implementation of linklist

Define your own recursive implementation of LinkList in a separate file called "RecLinkedList.java". Create an object of RecLinkedList to be used in storing and handling employees' data.

  Create a splash screen for the tgc application

To complete your splash screen please use the information below: Create a splash screen for the TGC application that displays: the application's name.

  Write program to implement autocomplete for given set

CPS 350- Write a program to implement autocomplete for a given set of N terms, where a term is a query string and an associated nonnegative weight. That is, given a prefix, find all queries that start with the given prefix, in descending order of ..

  Implement the enhancements to your survey class

Implement the enhancements to your Survey class according to the requirements presented above. The Survey class should have a method called "topRatedQuestion()," which performs an analysis of all responses for each question.

  Have an array of integers with user input instead of given

change the current code to have an array of integers with user input intead of given input from the main where it says int[] a=....; And also from a text file but the same numbers as what is given in main.

  Implement a fishlake simulation similar to the previous

implement a fishlake simulation similar to the previous assignment. you will then make adjustments to accommodate class

  Program which defines two unconstrained arrays

The enclosed Java code was suppose to address the following problem, where I require in giving comments/criticism/remarks if possible with respect to the Java coding standards.

  Write a program to store in a 2-d boolean array

Write a program to store in a 2-D boolean array of size 5 and 10 a true value if a random value is less than 0.5 else false. Print only the indexes of cells with true value.

  Create an array of objects and fill it from a file

CS1110- create an array of objects and fill it from a file or the user input. All manufacturers have the same basic elements in the televisions they produce as well as many options.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd