Suppose you are designing a part of a program for a medical robot that has a sensor returning an x- and y-location (measured in cm). You need to check whether the sensor location is inside the circle, outside the circle, or on the boundary (specifically, having a distance of less than 1 mm from the boundary). Assume the circle has center (0, 0) and a radius of 2 cm. Give a set of test cases.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Big Java Late Objects
Additional Engineering Textbook Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Data Mining for Business Analytics: Concepts, Techniques, and Applications with XLMiner
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
- Write a graphical program to trace a random walk (see previous two prob-lems) in two dimensions. In this simulation you should allow the step to be taken in any direction. You can generate a random direction as an angleoff of the x axis. angle = random() * 2 * math.piarrow_forwardWrite a program (in MATLAB) to read how many pixels are in "cameraman.tif", and add a white vertical line in the center of the ?(image (cameraman.tifarrow_forwardImplement the problem below in Python using mpi4py. Submit the code of your program and a brief report. The report should describe the design of your program, and demonstrate the results of running your program. n-body solver. Implement a parallel n-body solver with n = 10 particles. You may randomly generate the masses, initial velocities, and initial positions of all particles at the beginning. Compute the positions of all particles after 1 second. Compare the results by using 0.1s, 0.01s, and 0.001s as the time in each timestep, respectively.arrow_forward
- The Problem: You are coding a graphics filter that process each of an image through a filter. Each pixel is defined a triplet of real numbers (R,G,B) each of which is between 0 and 255.The filtering algorithms need to work on real numbers in order to do their job. But examining the program you discover that they only need two digits of accuracy. Any additional digits is just overkill.arrow_forwardYou work for a company that has warehouses of items. The items are all packaged in boxes that are roughly the same size. Each warehouse has some shelves in it. The shelves all hold the same number of boxes. To keep things from getting confusing, a shelf will only contain one kind of item on it, and a warehouse will have at most one shelf storing a given kind of item. (If the shelf is full, that item would go to a different warehouse to make sure that items are evenly distributed, but your code won’t track multiple warehouses.) You will create a Warehouse class to simulate a warehouse according to the above description. If you would like to make use of another class of your design, declare it inside the Warehouse class (this is called an inner class). It is possible to create an efficient solution without having to do this. You can imagine each shelf sitting in a long line; what kind of data structure have we seen that can take advantage of this? If each shelf has multiple properties,…arrow_forwardYou work for a company that has warehouses of items. The items are all packaged in boxes that are roughly the same size. Each warehouse has some shelves in it. The shelves all hold the same number of boxes. To keep things from getting confusing, a shelf will only contain one kind of item on it, and a warehouse will have at most one shelf storing a given kind of item. (If the shelf is full, that item would go to a different warehouse to make sure that items are evenly distributed, but your code won’t track multiple warehouses.) You will create a Warehouse class to simulate a warehouse according to the above description. If you would like to make use of another class of your design, declare it inside the Warehouse class (this is called an inner class). It is possible to create an efficient solution without having to do this. You can imagine each shelf sitting in a long line; what kind of data structure have we seen that can take advantage of this? If each shelf has multiple properties,…arrow_forward
- Python.. if you are trying to measure the mean of random variable Z. Z is Gaussian, with a mean of 66, and a standard deviation of 12. if we want to measure the value of Z a total of 100 times in a million parallel universes. Simulate the million mean values that you get from the experiment in the million parallel universes and plot a histogram. Hint: You can generate the data from all million universes with one numpy.random.normal() command.arrow_forwardYou are given an instance of a problem where you have an n x n grid of squares. Each square can be unpainted or can have a hole, so you cannot go on the square with a hole. The objective is to paint all the squares that do not have a hole. You start in the square (0,0) which is unpainted. The actions you can do are: (1) paint the square you are on if it is not painted; (2) move, either vertically or horizontally, to an adjacent square inside the grid that is not painted and does not have a hole. a. Describe a state-space representation for the problem, specifying the state representation, the initial state, the goal condition, and the actions. b. Is the state space finite? Is it a tree or a graph? c. Propose a heuristic for the problem. Is your heuristics admissible or not? Explain briefly your answerarrow_forwardThe register we discussed in class has two inputs, D and clock, and one output, Q. If you are interested, you can access a simulator of this circuit at http://www.falstad.com/circuit/e-edgedff.html (note that that simulator has an extra output, !Q, below Q). If D is 1 as clock transitions from 0 to 1, which of the following is true? A. Q is (or soon becomes) 0 B. Q is (or soon becomes) 1 C. Q oscillates between 0 and 1 D. Q holds a steady value, which could be 0 or 1arrow_forward
- Suppose you follow a certain stock in the stock exchange and record the daily values of the stock you follow for a certain period (Let's assume that the values recorded for each day represent the actual price of the stock on that day). After the period is over, you want to make a simulation using the recorded values and determine the correct buying and selling days in order to take the most profitable position for that stock during this period. Naturally, in order to take the most profitable position, the purchase and sale days of the stock should be determined in such a way that the prices at the time of sale and purchase should be at the highest value compared to other alternatives, that is, we want to maximize the price difference between the two points. As an example, suppose a 4-day series is taken and the recorded price series is as follows: Day 1: $ 9Day 2: $ 1Day 3: $ 54th day: $ 4 In this case, if the purchase day is the 2nd day and the selling day is the 3rd, this…arrow_forwardDraw the flow chart for the following: This project will use an ultrasonic sensor to detect motion and light different leds and sound a buzzer depending on the distance of an object from the sensor: We will use Green, Yellow, Red leds and buzzer to signal distance of object as follows: Light the GREEN LED if the object is greater than 100cm away from sensor Light the YELLOW LED if the object is between 70cm and 100cm away from sensor Light the RED LED if the object is less than 70cm away from the sensor and sound the buzzerarrow_forwardFor your first program, you are to write a simple Dodgeball simulation. In this simulation, we will have nplayers, and one ball. One player, the "thrower," will have the ball. The thrower will throw the ball at anotherplayer, the "target." The target could catch the ball, could be hit by the ball, or the ball could completely missthe target. If the target catches the ball, then the thrower is out of the game (and the target becomes the nextthrower.) If the ball hits the target, then the target is out of the game. If the ball misses the target, neitherplayer is out. In the latter two cases, any one can pick up the ball and become the next thrower. The game isover when only one player is left.In this simple version, the players (initially n players) will stand in a circle. The thrower will always countthe players to his/her right, and then throw the ball at the dth player, who becomes the target. The target willalways catch the ball, so that the thrower will be out of the game (and will…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education