Assignment 0/0 2 /0 8 /0 16 Version: 3.2a Last Updated: 9/20/ :29 PM Binary Ones Comp Twos Comp

Similar documents
GRADE 6 FLORIDA. Division WORKSHEETS

10! !. 3. Find the probability that a five-card poker hand (i.e. 5 cards out of a 52-card deck) will be:

N2-1. The Voltage Source. V = ε ri. The Current Source

6.1 Reciprocal, Quotient, and Pythagorean Identities

Derangements. Brian Conrey and Tom Davis and March 23, 2000

Investigation. Name: a About how long would the threaded rod need to be if the jack is to be stored with

IAS 2.4. Year 12 Mathematics. Contents. Trigonometric Relationships. ulake Ltd. Robert Lakeland & Carl Nugent

CHAPTER 12 Circles and Circular Solids

5.2 Trigonometric Ratios of Any Angle

Exercise 1 (MC Question)

Discrepancies Between Euclidean and Spherical Trigonometry. David Eigen

Analysis of Occurrence of Digit 0 in Natural Numbers Less Than 10 n

Chapter 5: Trigonometric Functions of Angles

Discussion #7 Example Problem This problem illustrates how Fourier series are helpful tools for analyzing electronic circuits. Often in electronic

4 Trigonometric and Inverse Trigonometric Functions

1 Trigonometric Functions

Cyclic Constellation Mapping Method for PAPR Reduction in OFDM system

Statement of Works Data Template Version: 4.0 Date:

Real-time Self Compensating AC/DC Digitally Controlled Power Supply

where and are polynomials with real coefficients and of degrees m and n, respectively. Assume that and have no zero on axis.

Trigonometry: Angles between 0 and 360

Analysis of a Fractal Microstrip Patch Antenna

Steve Alpern, Thomas Lidbetter, Alec Morton, and Katerina Papadaki Patrolling a pipeline

CS61C : Machine Structures

CHEVY TH350/700R AUTO TRANSMISSION TO JEEP 4.0L, ENGINE BLOCKS NEW STYLE

THE UNIVERSITY OF NEW SOUTH WALES. School of Electrical Engineering & Telecommunications

Spectrum Sharing between Public Safety and Commercial Users in 4G-LTE

Low-Complexity Time-Domain SNR Estimation for OFDM Systems

Demosaicking using Adaptive Bilateral Filters

Gas Tube Arresters. Certifications, Device Selection Purpose, Operation, Installation Part Number Construction, Part Marking. General Information

The Periodic Ambiguity Function Its Validity and Value

The phenomenon of incoherent signal interference

A multichannel Satellite Scheduling Algorithm

Multiagent Reinforcement Learning Dynamic Spectrum Access in Cognitive Radios

AMERICAN NATIONAL STANDARD

Week 5. Lecture Quiz 1. Forces of Friction, cont. Forces of Friction. Forces of Friction, final. Static Friction

This article presents the

Development of Corona Ozonizer Using High Voltage Controlling of Produce Ozone Gas for Cleaning in Cage

INCREMENTAL REDUNDANCY (IR) SCHEMES FOR W-CDMA HS-DSCH

Design of A Circularly Polarized E-shaped Patch Antenna with Enhanced Bandwidth for 2.4 GHz WLAN Applications

Investigate Surface Area of Three-Dimensional Objects

Signal Extraction Technology

Begin this assignment by first creating a new Java Project called Assignment 5.There is only one part to this assignment.

Key Laboratory of Earthquake Engineering and Engineering Vibration, China Earthquake Administration, China

Sinusoidal Oscillators

Configurable M-factor VLSI DVB-S2 LDPC decoder architecture with optimized memory tiling design

The mathematical structure known as a graph has the valuable feature of

Optimal Design of Smart Mobile Terminal Antennas for Wireless Communication and Computing Systems

f o r o l d e r g i r l s Discover Northwest Indiana I m coming home, it s plain to see. I still got Indiana soul in me. tofrom

Efficient Power Control for Broadcast in Wireless Communication Systems

Localization Algorithm for a mobile robot using igs

The Experimental Study of Possibility for Radar Target Detection in FSR Using L1-Based Non-Cooperative Transmitter

School of Electrical and Computer Engineering, Cornell University. ECE 303: Electromagnetic Fields and Waves. Fall 2007

Journal of Applied Science and Agriculture

A cone is a solid formed by one circular base and a vertex.

ONE-WAY RADAR EQUATION / RF PROPAGATION

UNCERTAINTY ESTIMATION OF SIZE-OF-SOURCE EFFECT MEASUREMENT FOR 650 NM RADIATION THERMOMETERS

Sliding Mode Control for Half-Wave Zero Current Switching Quasi-Resonant Buck Converter

CMPT 125/128 with Dr. Fraser. Assignment 3

CCSDS Coding&Synchronization Working Group March Washington DC, USA SLS-C&S_08-CNES02

City of Medford, Oregon STORMWATER MANAGEMENT PROGRAM (SWMP) TO MEET NPDES PHASE II MS4 COMPLIANCE

Small Loop Antenna and Duality Theorem

Parameters of spinning AM reticles

Figure Geometry for Computing the Antenna Parameters.

For Teachers and Self Learning. train the trainer. for the DEDICATED ONLY. by ryan mcclelland

IEEE Broadband Wireless Access Working Group < Modifications to the Feedback Methodologies in UL Sounding

Project 2 - Blackjack Due 7/1/12 by Midnight

Experimental Investigation of Influence on Non-destructive Testing by Form of Eddy Current Sensor Probe

NICKEL RELEASE REGULATIONS, EN 1811:2011 WHAT S NEW?

Minimizing Ringing and Crosstalk

New Link Lift Watch User guide

Randomized Self-Assembly for Exact Shapes

77 GHz ACC Radar Simulation Platform

Surface Areas of Cylinders ACTIVITY: Finding Surface Area. ACTIVITY: Finding Area. How can you find the surface area of. a cylinder?

Optimal Strategies in Jamming Resistant Uncoordinated Frequency Hopping Systems. Bingwen Zhang

Proposal of Circuit Breaker Type Disconnector for Surge Protective Device

Design of FIR Filter using Filter Response Masking Technique

Fault severity diagnosis of rolling element bearings based on kurtogram and envelope analysis

Chapter 9 Cascode Stages and Current Mirrors

MX100/MW100 Data Acquisition Unit Installation and Connection Guide

Overlapping community detection in signed networks

ISSN: [Reddy & Rao* et al., 5(12): December, 2016] Impact Factor: 4.116

51. IWK Internationales Wissenschaftliches Kolloquium International Scientific Colloquium

1 Performance and Cost

Wireless Communication (Subject Code: 7EC3)

Bouncy Dice Explosion

STACK DECODING OF LINEAR BLOCK CODES FOR DISCRETE MEMORYLESS CHANNEL USING TREE DIAGRAM

Analysis of the optimized low-nonlinearity lateral effect sensing detector

Near-field emission prediction of CESAME

On Shooting a Moving Vehicle with Data Flows

Feasibility of a triple mode, low SAR material coated antenna for mobile handsets

Determination of The Winding Inductances Of A Two-Phase Machine.

Sensorless control of induction motors

ScienceDirect. Simplified Generation of Electromagnetic Field within EMC Immunity Test Area

Optimization of the law of variation of shunt regulator impedance for Proximity Contactless Smart Card Applications to reduce the loading effect.

Performance Analysis of Z-Source Inverter Considering Inductor Resistance

Antenna fundamentals: With answers to questions and problems (See also Chapter 9 in the textbook.)

2D Coding for Future Perpendicular and Probe Recording

Distributed Spectrum Allocation via Local Bargaining

STATUS REPORTS USING SAS. Dagnlja V. Spuntel1s, Merck Sharp and Dohme Rahway, N.J. faci1~tated. A. System Requirements. 1. A simple input mechanism

Transcription:

* Dynamic Memoy *Big O Notation*Stacks *Exteme Pogamming*Selection Sot*Insetion Sot*Watefall Model Sting*Aays*AayList*Client Seve*Atificial Intelligence*Inheitance*Files*Video Games*Shot cicuit evaluation* Assignment 0/0 2 /0 8 /0 16 Vesion: 3.2a Last Updated: 9/20/2017 10:29 PM Binay Ones Comp Twos Comp Summe Assignment Welcome to the AP Compute Science Pogam! This is a challenging and fun couse as we delve deepe into compute science. Attached you will find summe assignments to be completed by the fist day of school next yea. 1

The two aticles ae fom the Oacle page and they descibe the basic concepts of classes and objects. Hee ae the URL s http://java.sun.com/docs/books/tutoial/java/concepts/object.html http://java.sun.com/docs/books/tutoial/java/concepts/class.html 1. Pepae a 6-8 slide powepoint pesentation o google slides on the aticles descibing the diffeences. If necessay, use the intenet and compute books to exploe the diffeences between classes and objects, etc. The following pogams can be ceated using eithe the console o Swing. 2. Wite a pogam that takes as inputs the lengths of thee sides of a tiangle and displays; fist, whethe o not the 3 values epesent a tiangle and then whethe the tiangle is scalene, isosceles, o equilateal. Useful facts: In a tiangle, the longest side must be less than the sum of the othe two sides. A scalene tiangle has all sides unequal. An isosceles tiangle has two sides equal. An equilateal tiangle has all sides equal. HINTS fo Testing: When testing, make sue you test with all sides the same and you pogam doesn t epot the tiangle to be both isosceles and equilateal. 2

3. DO NOT USE Math.andom() fo this assignment!!!! This assignment needs to have a andom numbe geneato using the java.util.random class I will be using a seed to test this. Only geneate numbes when you ae using them to oll dice. See below fo the esults expected given a seed of 10! In the game of caps, a playe olls 2 six sided dice and adds up the sum. The fist oll is special; a playe can eithe win o lose instantly on the fist oll. DO NOT USE nextint(11) + 2; THIS DOES NOT SIMULATE PROBABILITY AND THE LIKELYHOOD OF 7 COMING UP MOST OFTEN!!! If the fist oll is a 7 o 11, INSTANT WINNER. The ound is ove. If a playe olls a 2, 3 o 12, INSTANT LOSER. If none of the above ae olled, the playe goes into a phase whee they continually oll 2 dice until one of two things happens; 1) the playe olls the intial numbe (known as the point) the playe WINS 2) the playe olls a 7, the playe LOSES. Examples of dice oll sequences and esults i. Roll a 7 on fist oll -> WIN ii. Roll an 11 on fist oll -> WIN iii. Roll a 2 on fist oll ->LOSE iv. Roll a 3 on fist oll -> LOSE v. Roll a 12 on fist oll -> LOSE vi. Roll a 5, 9, 12, 6 and then a 5 to win since you eolled the point vii. Roll a 5, 9, 12, 6 and then a 7 to lose since you olled a 7 when attempting to eoll the point viii. Roll 8, 2, 3, 11, 12, 9, 3, 3, 5, 9, 10, 8 to win since you eolled the point Make a caps game in the console o Swing that stats the playe out with 100 chips(o cookies o pape clips, bid eggs, whateve) 3

Befoe each game, the use is asked to make a wage (by default, just wage 10%) Then allow the use to play the game by olling the dice. Use the space ba o key o something to allow them to see each oll. Afte the game is won o lost, subtact o add chips and then display them to the sceen. If the use is out of chips, then Sample Results fo Seed 10 fom Alex Heman (2017) Poject un: You have 100 chips. How many do you want to bet? 1 Type '' to oll the dice. You olled a 5 Type '' to oll the dice again. You olled a 5 YOU WON!!!! You got 1 chips. $$$$$$$$$$$$$$$$ WINNER $$$$$$$$$$$$$$$$$$$ You have 101 chips. How many do you want to bet? 2 Type '' to oll the dice. You olled a 10 Type '' to oll the dice again. You olled a 7 You capped out and lost 2 chips. ================LOSER====================== You have 99 chips. How many do you want to bet? 2 Type '' to oll the dice. You olled a 9 Type '' to oll the dice again. 4

You olled a 8 Type '' to oll the dice again. You olled a 5 Type '' to oll the dice again. You olled a 5 Type '' to oll the dice again. You olled a 7 You capped out and lost 2 chips. ================LOSER====================== You have 97 chips. How many do you want to bet? 3 Type '' to oll the dice. You olled a 7 YOU WON!!!! You got 3 chips. $$$$$$$$$$$$$$$$ WINNER $$$$$$$$$$$$$$$$$$$ You have 100 chips. How many do you want to bet? 2 Type '' to oll the dice. You olled a 8 Type '' to oll the dice again. You olled a 7 You capped out and lost 2 chips. ================LOSER====================== You have 98 chips. How many do you want to bet? 2 Type '' to oll the dice. You olled a 8 Type '' to oll the dice again. You olled a 6 Type '' to oll the dice again. You olled a 6 5

Type '' to oll the dice again. You olled a 6 Type '' to oll the dice again. You olled a 4 Type '' to oll the dice again. You olled a 4 Type '' to oll the dice again. You olled a 10 Type '' to oll the dice again. You olled a 6 Type '' to oll the dice again. You olled a 8 YOU WON!!!! You got 2 chips. $$$$$$$$$$$$$$$$ WINNER $$$$$$$$$$$$$$$$$$$ You have 100 chips. How many do you want to bet? 10 Type '' to oll the dice. You olled a 4 Type '' to oll the dice again. You olled a 11 Type '' to oll the dice again. You olled a 2 Type '' to oll the dice again. You olled a 8 Type '' to oll the dice again. You olled a 12 Type '' to oll the dice again. You olled a 10 6

Type '' to oll the dice again. You olled a 12 Type '' to oll the dice again. You olled a 4 YOU WON!!!! You got 10 chips. $$$$$$$$$$$$$$$$ WINNER $$$$$$$$$$$$$$$$$$$ You have 110 chips. How many do you want to bet? 3 Type '' to oll the dice. You olled a 4 Type '' to oll the dice again. You olled a 4 YOU WON!!!! You got 3 chips. $$$$$$$$$$$$$$$$ WINNER $$$$$$$$$$$$$$$$$$$ HINTS fo Testing: If you seed the Random numbe geneato object, then you will get the same sequence of pseudo andom numbes each un of the pogam. Fo example, Random = new Random(100); will cause all calls to.nextint(n); to give the same sequence. This helps you find the epeated case you ae looking fo without testing foeve. Be sue you ve coveed all cases. NOTE: Console pogammes will be witing a loop while Swing uses will have to keep tack of whethe it is a eoll o initial oll. Swing utilizes its own loop to keep checking fo any events that might occu and epot those events to the pogam handles. Theefoe, although thee is a loop, it has been ceated by the authos of the Swing GUI developes. To deal with this, use a global vaiable inside you Fame to detemine if the next oll is an initial oll o eoll. Fo example, public CapsFame extends javax.swing.jfame{ boolean fistroll = tue; } 7

This vaiable can be used to infom the actionpefomed method inside the CapsFame when a oll is a fist oll and when it is a eoll. Just flip the boolean vaiable. NOTE: Swing GUI s MUST BE ABLE to show the sequence of olls fo ease of testing. To do this, use a JTextAea that can show 6 ows of numbes. Each oll can be appended to the JTextAea so I can see the sequence of olls. 4. A pefect numbe is a positive intege such that the sum of the divisos equals the numbe. Thus, 28 = 1 + 2 + 4 + 7 + 14 is a pefect numbe. If the sum of the divisos is less than the numbe, it is deficient. If the sum exceeds the numbe, it is abundant. Wite a pogam that takes a positive intege as input and displays a message box that indicates whethe the numbe enteed is pefect, deficient, o abundant. You pogam should define the following thee methods: NOTE: MAKE SURE YOU HAVE ALL METHODS AND PARAMETERS, YOU WILL NOT RECEIVE FULL CREDIT UNLESS YOU STRUCTURE YOUR PROGRAM AS YOU SEE BELOW!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! main boolean isdiviso (int num, int diviso) int divisosum (int numbe) The method isdiviso etuns tue if the diviso paamete is a diviso ofthe numbe paamete, and false othewise. The divisosum method uses isdiviso to accumulate and etun the sum of the pope divisos of the numbe paamete. Be sue to design and test the pogam incementally, that is, veify that isdiviso woks coectly befoe using it in divisosum. Fom a console pogam, the thee methods might look like this; /* pompts the use fo a numbe and then epots whethe the numbe is pefect, 8

deficient o abundant, calls the divisosum method to find the numbe of pope divisos fo any numbe*/ public static void main(sting[] ags) { //How do you call divisosum fom hee? // int sum = divisosum(num); //calls method and stoes etun value in sum } /* takes in an intege and calls isdiviso in a loop to detemine whethe o not each possible diviso evenly divides the numbe*/ public static int divisosum (int numbe) } /* takes in an two integes, etuns tue if the second is a diviso of the fist*/ public static boolean isdiviso (int num, int diviso) { } public static void main() Gathe input fom use Call divisosum to find out sum of pope divisos 15 9 public static int divisosum(int num) Loops though possible candidates, calls isdiviso to see if each potential diviso is actually a diviso LOOP MULTIPLE TIMES TO CALL isdiv 15,2 false public static boolean isdiviso(int num, int div) etuns tue o false depending upon the elationship between num and div 9

5. A standad expeiment is to dop a ball to see how high it bounces. Once the "bounciness" of the ball is detemined, the atio gives a bounciness index. Fo example, if a ball dopped fom a height of 10 feet bounces 6 feet high, the index is 0.6 and the total distance taveled by the ball is 16 feet afte one bounce. If the ball continues bouncing, the distance afte two bounces would be 10 + 6 + 6+ 3.6 = 25.6 feet. Note that the distance taveled fo each bounce is the distance to the floo plus 0.6 of that distance as the ball comes back up. The ball, theefoe, hoves in the ai. Wite a pogam that takes as inputs the initial height of the ball (in feet), the index of the ball's bounciness, and the numbe of times the ball is allowed to continue bouncing. The pogam should output the total distance taveled by the ball. At some point in the pocess, the distance taveled by the ball afte a bounce might become negligible, fo example, less than 0.001 feet. If that stage is eached, teminate the pocess and output the total distance. (This could happen if fo example, we attempted to dop a ball fo 10,000 bounces). Hee ae un-thoughs that will be helpful to you. Fo Chis Du, Rahul Shah and Jason Cantebuy!!!! 10

Case # Initial Height Bounciness Bounces Distance Beakdown 1 50.4 5 115.472 see below 2 10.8 3 43.92 see below 3 1.2 8 1.4992 only 4 and a half bounces Make sue theshold set to.001 fo case 3!!! EXAMPLE 1 What Height to Stat? 50 Index of Bounce?(.1->.9.4 How many bounces? 5 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Down:50.0 Up: 20.0 Down:20.0 Up: 8.0 Down:8.0 Up: 3.2 Down:3.2 Up: 1.2800000000000002 Down:1.2800000000000002 Up: 0.5120000000000001 11

115.47200000000001 EXAMPLE 2 What Height to Stat? 10 Index of Bounce?(.1->.9).8 How many bounces? 3 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Down:10.0 Up: 8.0 Down:8.0 Up: 6.4 Down:6.4 Up: 5.120000000000001 43.92 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ EXAMPLE 3 What Height to Stat? 1 Index of Bounce?(.1->.9).2 12

How many bounces? 8 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Down:1.0 Up: 0.2 Down:0.2 Up: 0.04000000000000001 Down:0.04000000000000001 Up: 0.008000000000000002 Down:0.008000000000000002 Up: 0.0016000000000000005 Down:0.0016000000000000005 Up: 3.2000000000000013E-4 Since up is less than 0.001 we outta hee! 1.4992 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 13

6. Ceate an account on the codingbat.com web site. This site allows you to type in the bodies of methods and see if they ae coect online. Shae you account out to mhanleyc@hotmail.c om unde the pefs fo codingbat. You fist and last name in the pefeences must be you actual fist and last name so I don t have to guess who is who. Complete the following codingbat poblems; Complete the following Wamup 1 poblems and save them on codingbat so I can veify, comments helpful but not equied i. sleepin, monkeytouble, sumdouble, diff21, paottouble, makes10, icyhot, in1020, hasten, loneteen, intmax, close10, in3050, max1020, lastdigit Complete ALL the Logic 1 poblems (THERE ARE 30 HERE!!!!) Complete ALL the Logic 2 poblems (THERE ARE 9 HERE!!!!) You can do it, don t copy the answes fom the web, stuggle though and email me if you ae having gande toubles, hanlchi@shenet.og 14

Poject Name Class 1 Name Class 2 Name Class 3 Name Class 4 Name Summe Assignment TiangleCalculato PefectNumbeFinde Caps BounceCalculato Rubic TiangleCalculato 25 PefectNumbeFinde 25 Caps 25 Bounciness Simulation 25 Powepoint on Object oiented 30 pogamming Comments 10 CodingBat Poblems 100 TOTAL 240 15