Write a program that enables a user to enter desired sum

Assignment Help Computer Engineering
Reference no: EM131935364

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.

Reference no: EM131935364

Questions Cloud

Agent of social change in educational community : In what ways can you set goals to become an advocate for your students and an agent of social change in your educational community?
Explain how did author establish the significance of study : Explain how did the author establish the significance of the study? In other words, why should the reader care about this study?
Explain a protocol for the diagnosis and management : Explain a protocol for the diagnosis, management, and follow-up care of this disorder. Explain the disorder you selected, including its pathophysiology.
What was your plan for diagnostics and primary diagnosis : What was your plan for diagnostics and primary diagnosis? What was your plan for treatment and management? What were your differential diagnoses?
Write a program that enables a user to enter desired sum : 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.
Basic layout of one of the spaces : Sketch the basic layout of one of the spaces suggested at the beginning of this chapter (home, work, third place).
Explore your experience in assessing and managing patient : Explore your experience in assessing and managing the patient and his or her family. Include details of your aha moment in identifying the patient's disorder.
Explain one internal and external method for dissemination : Explain one internal and one external method for the dissemination of your EBP project results. For example, an internal method may be the hospital board.
Construct an argumentative : Your goal is to read the text (or selection), determine what it is saying, and then construct an argumentative, interpretive thesis.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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