Write a program that enables a user to enter in a desired


1. Write a program that enables a user to enter in a desired sum for two dice, and then simulates the rolling of two dice until the sum is rolled. After each pair of rolls the program should output what the rolls were and the sum. For example:

2. You are now working for baseball statistics company in need of a new program for computing a baseball batter's slugging percentage.
A batter's slugging percentage is based on the number of opportunities they have to hit the baseball, also called their at bats, and how many bases they touched at each of those at bats.

For example, if a baseball player is at bat and they hit the ball for a double, this indicates they touched two bases. If the player gets a home run, this indicates they get to touch four bases, the maximum possible. If the player is at bat and they do not get a hit, then they touch 0 bases. We then compute the slugging percentage as the total number of bases the player touched divided by the number of at bats they had.

Your program will prompt a user to enter the number of bases touched for each of a player's at bats (i.e., 0, 1, 2, 3, or 4) until they enter a -1 to stop entering bases touched. Then the program should report the total number of at bats entered and the slugging percentage.

3. You are to build a text-based version of the game Mastermind (Links to an external site.)Links to an external site.. The game is played with two-players: the code master and the code breaker.

The code master chooses four different colored pegs to form a code. The pegs can be any of six colors: Red, Orange, Yellow, Green, Blue, Purple. For example the code master might choose Orange, Orange, Blue and Purple as the four peg code. We could abbreviate this code as OOBP.

The code breaker then makes guesses to try and determine the code. For example, the code breaker could guess Blue, Yellow, Orange, Purple, which we could abbreviate as BYOP. After the guess is made, the code master provides two types of feedback on the guess:

1. a count of how many colored pegs are in the correct position (e.g., if the code is OOBP and the guess is BYOP, then the Purple peg is in the correct position so the master would say 1 peg is in the correct position)

2. a count of how many pegs are a color in the code, but in the wrong position (e.g., if the code is OOBP and the guess is BYOP, then the Blue and Orange pegs in the guess are present in the code but in the wrong positions, so the master would say 2 pegs are the correct color).

One important thing to notice: if the code is OOBP and the guess is BOOO, then the feedback should 1 peg is in the correct position (the first O in the guess) and 1 peg is the correct color but in the wrong position, not 2. The O's in the 3rd and 4th position of the guess should not both be counted because there are only two O's in the code and one of them is already covered by the O in the correct position. (Frankly, this is the most difficult part of this assignment and it is strongly recommended you work out the other portions of this program before you get bogged down in this problem.)

4. You are to build a text-based version of the game Mastermind (Links to an external site.)Links to an external site.. The game is played with two-players: the code master and the code breaker.

The code master chooses four different colored pegs to form a code. The pegs can be any of six colors: Red, Orange, Yellow, Green, Blue, Purple. For example the code master might choose Orange, Orange, Blue and Purple as the four peg code. We could abbreviate this code as OOBP.

The code breaker then makes guesses to try and determine the code. For example, the code breaker could guess Blue, Yellow, Orange, Purple, which we could abbreviate as BYOP. After the guess is made, the code master provides two types of feedback on the guess:

1. a count of how many colored pegs are in the correct position (e.g., if the code is OOBP and the guess is BYOP, then the Purple peg is in the correct position so the master would say 1 peg is in the correct position)

2. a count of how many pegs are a color in the code, but in the wrong position (e.g., if the code is OOBP and the guess is BYOP, then the Blue and Orange pegs in the guess are present in the code but in the wrong positions, so the master would say 2 pegs are the correct color).

One important thing to notice: if the code is OOBP and the guess is BOOO, then the feedback should 1 peg is in the correct position (the first O in the guess) and 1 peg is the correct color but in the wrong position, not 2. The O's in the 3rd and 4th position of the guess should not both be counted because there are only two O's in the code and one of them is already covered by the O in the correct position. (Frankly, this is the most difficult part of this assignment and it is strongly recommended you work out the other portions of this program before you get bogged down in this problem.)

5. You are to write a graphical program that tracks if a user clicks inside or outside of a box. In the image below you will notice two blue boxes and many circles. Notice that the blue circles are inside the boxes, and the red circles are outside the boxes.

Your goal is to complete the P4_BoxClick class such that it:

1. draws two boxes (i.e., rectangles)

2. draws a circle where a user clicks on the panel

3. colors the circle blue if the click is inside one of the boxes, or red if it the click is outside one of the boxes

In the P4_BoxClick class I have provided you with a few things:

• The main method creates a DrawingPanel object that is 400 pixels wide by 400 pixels high

• It creates a mouse click handler for which you do not need to worry about the mechanics, all you need to know is that when the mouse is clicked on the panel it will call the `handleMouseClick` method that I provided.

• The `handleMouseClick` method has three parameters: the graphics context object, an x coordinate, and a y coordinate that correspond to the (x, y) location where the user clicked

The location and size of the boxes are up to you, but they must have a minimum width and height of 20 pixels. The circles for the clicks should have a diameter of at least 3 pixels and be drawn centered on the (x, y) coordinate on which the user clicked.
You should not modify the signature of the `handleMouseClick` method. This can lead to a few magic numbers in your solution, but that's okay for this problem.

Solution Preview :

Prepared by a verified Expert
Computer Engineering: Write a program that enables a user to enter in a desired
Reference No:- TGS02730836

Now Priced at $70 (50% Discount)

Recommended (94%)

Rated (4.6/5)