The driver simulates a simplified black jack game


PART A

1. Implement a method countByValue() that takes two integer parameters, valueand end, bigger then value. The method prints multiples of value up to end (inclusive if it is a multiple of value) and starts a new line after 10 values have been displayed.

2. Implement a method isPerfect()
that takes an integer parameter, num, and returns true if num is perfect and false otherwise. A number is perfect if it equals the sum of all the numbers that divide evenly into it. For example, 6 is perfect because 1, 2, and 3 divide evenly into it, and their sum is 6; however, 12 is not a perfect number because 1, 2, 3, 4 and 6 divide evenly into it, and their sum is greater
than 12.

3. Implement a method allPerfect()
that takes an integer parameter end. The method prints every perfect number from 1 to end. Use the method isPerfect() above to check if a number is
perfect. 

4. Implement a method commonString()
that takes two string parameters, str1,
str2. The method returns the string containing common corresponding
characters. For example, if str1="blueberry pankcake", str2="banana muffins", the method returns "bn". NOTE: Strings may have different lengths.

5. Implement a method isPalindrome()
that takes a string parameter, str. The
method returns true if str is a palindrome and false otherwise. A palindrome is a
phrase that reads the same backward and forward without regarding
capitalization or punctuation. For example, "abracadabra", "Madam, I'm Adam",
"Dot saw I was Tod" are palindromes. 

NOTE Remember to put all method in a class for testing.

PART B

6. Define
a class called Card that represents a playing card from a standard deck. The card has a suit, which can be one of the strings: "spades", "hearts","diamonds" or "clubs". A spade, heart, diamond, or club has one of the 13
values: ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, or king. The class must include the following data fields and
methods:

suit //the card's
suit
value//the
card's value. Use values 1-13, with 1 representing ace and 11-13, jack, queen
and king, respectively
default
constructor //with default suit
"spades" and default value 1
constructor //creates a card with a
specified suit and value 
getter
method for each data 
setter
method for each data 
toString //returns
the string "x of suit", where x is
the card value and suit is the suit
equals //takes
another Card object parameter and returns True if cards have same suit and
value, False otherwise. 

7. Using
the Card class defined above, design and implement a driver class called BlackJack.
The driver simulates a simplified black jack game between computer and user.
The rules are below: 
- First two cards are dealt
for each player.
- If the dealer's hand has a value of 21 at this point, then the dealer wins. Otherwise, if the user has 21, the user wins. The dealer also wins on a tie. 
- If no one wins, the user is asked repeatedly for either a hit or stand. 
- If the user hits, a card is
dealt. 
- If the user's total
value is >21, the user loses. 
- If the user stands, he/she is
not asked again. 
-The dealer is repeatedly dealt a card while the total value <=16. (Cards
are "open")
- if the total value >21,
the user wins and game ends 
- At end, total hands are compared. If dealer has bigger or same hand as user,
the user loses. 
-Otherwise, the user wins.

8. Using the Card class defined above, design and implement a
driver class called CardsRun whose main method repeatedly deals two cards until two same cards are dealt, in which case the longest run of "hearts' suit and
value <9 is dealt for both cards.

PART C (Arrays)

9.. Design and implement an application that reads an arbitrary number of integers that are in the range 0 to 50 inclusive and counts how many occurrences of each are entered. After all input has been processed, print all of the values (with the number of occurrences) that are entered one or more times. (Hint: can use idea from LetterCount program in the book)

10. Write a method named summit that accepts 2 integer arrays named gamma and delta. If the arrays are the same size the method will return an array of the sum of the corresponding elements. If they are of different sizes the method will return an array of 10 elements where all of the elements are set to -1. (Obviously, you need to put this method in a class and create an application to generate output.)

11. Create a class named ArrayMethods. No attributes. No Constructor (System will supply it). Implement the following methods which all take an integer array named list as a parameter:

(i). The method named setup that will initialize all of the odd elements to -1 and set the even elements to their index number.

(ii). The method named fibo will initialize the array to the Fibonacci sequence. This sequence starts with 1 and 2 as the first 2 elements and each element thereafter is the sum of the previous two elements. (1, 2, 3, 5, 8, 13...) NOTE Remember to put all method in a class for testing.

12. Implement a method named pieces that accepts an array of integers named array. The method will sum each group of 5 integers in the array and place the sum into another array named result. The method will return the new array. If the last group in the array does not contain a full group of 5 it is not to be included.
Ex: if the array consists of : {3, 6, 3, 2, 8, 1, 0, 4, 9, 1, 0, 1, 1, 6, 7, 3, 8, l, 2} there are 3 groups of 5 and 4 remaining. The new array would be of size 3 and the sum of the last 4 digits would not be included. 

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: The driver simulates a simplified black jack game
Reference No:- TGS093641

Expected delivery within 24 Hours