Ask Computer Engineering Expert

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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92774020
  • Price:- $70

Priced at Now at $70, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As