Question
Create a class named NumberGame and in that class, Write a function named isEven which takes in a single int parameter and returns a boolean.
Create a class named NumberGame and in that class, Write a function named isEven which takes in a single int parameter and returns a boolean. This function should return true if the given int parameter is an even number and false if the parameter is odd. Write a function named close10 which takes two int parameters and returns an int. This function should return whichever parameter value is nearest to the value 10. It should return 0 in the event of a tie. Note that Math.abs(n) returns the absolute value of a number. Write a method called sumTo that takes two int parameters and returns an int. This function should return the sum of all numbers from the smaller parameter to the larger parameter, inclusive. (i.e. given 2 and 4, returns 9. Because 2 + 3 + 4 = 9) (if given 4 and 2, returns 9 as well. Because 2 + 3 + 4 = 9)
Write a method named rollSnakeEyes which takes no parameters and does not return any value. This method should continually roll two dice and only terminate when both dice are equal to 1. You must roll both dice at the same time. For example, if one die is 1 you can not only roll the other die. For example, if one die is 1 you can not only roll the other die. Print the result of each roll to the console. (So if die one was a 4 and die two was a 6, print "4 6" to the console). Use '(int)(Math.random() * 6) + 1' to simulate a dice roll. (That code will always produce an int between 1 and 6)
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