Advanced Placement Computer Science Course Overview Course Policies Computer Science AP Syllabus Class Schedule Homework Labs Projects Extra Credit Study Material Grades Computer Science 2 AP Get Software Useful Resources Teacher Information |
Extra Credit for Computer Science AP
Prove Einstein wrong!
Einstein famously exclaimed his disbelief in the idea of quantum physics. Well, it's time to prove quantum physics (or rather a related idea). In a famous experiment, the three doors experiment, a person is given a choice of three doors. Behind one of the three doors is a prize, and behind the other two is nothing. The person selects a door, and the person running the experiment removes a door other than the one the person selected. The person running the experiment further gurantees that he or she did NOT remove the door with the prize. The person who is selecting is left with a dilemma: does the person stick with their original guess or do they switch to the remaining option. In reality, if the person switches, there is a 2/3rds chance that they will get the prize... but it's not immediatly obvious why, or if in fact this theory is correct. You are to write a computer simulation in java that will prove or disprove this idea. Have the computer randomly select between 3 values to be the prize, and then have it randomly pick again a slot having the computer act as the person selecting. Then have the computer "remove" one of the other two options making sure not to remove the correct one, and then have the computer either always stick with their choice, or always switch. Record the number of times, the selector "wins" and how many times they "lose". Run this simulation a million times, and then report the % of the time they won with their strategy. Do this individually and this is worth 5 points.
This class will need to allow all
fish to move to random locations on the board by DEFAULT without having
to modify the Fish class.
To do this, you will NEED to
write a neighborsOf method. This is defined in the Environment
interface, but implemented in the SquareEnvironment, a class which you
do NOT have access to. Just write a method that matches the
preconditions/postconditions of the one defined in Environment.
Demonstrate that this works by modifying SimpleMBSDemo to use it. This is worth a maximum 5 points.
Demonstrate that this works by
modifying SimpleMBSDemo to use it
This is worth a maximum of 5 points
This is worth a maximum of 5
points
Remember, mean means the
average.
Median means if the data were placed into ascending order, the median is the value in the center of that data. Mode means the most common number. (if there are multiple modes, you can report any of the modes) Display the outputs to the user via System.out.println This is worth a maximum of 5 points
This is worth a maximum of 5
points
This is worth a maximum of 5 points.
songs.txt should have this rough
format:
Hey Jude Achy Breaky Heart artists.txt should have this
rough format
Beatles, Please Please Me, Revolver, Rubber Soul, Abbey Road Rolling Stones, Let It Bleed, Exile on Main Street Britney Spears, Gag Me Baby One More Time This is worth a maximum of 5 points
For the game, you are two write a
class for a card that keeps track of what suit and what face value
there is for each card. The class should have a toString() method
that returns a String which gives the type of card (2, 3, Jack, etc)
and the suit of the card. The class also should have a
compareTo(Object ob) that will return 0 if the two cards have the same
value, -1 if you are smaller than the card being passed in as ob and +1
if your card has a higher value than ob.
You should then write code that will create cards randomly with a randomly selected type (2, 3, Jack, etc) and a randomly selected suit for two "sides", and then display which side wins each round by figuring out which one has the highest value by calling the compareTo method. And then display each round by using println and the toString() methods. An example output is as follows: Player1: Jack of Spades, Player 2: Queen of Hearts Winner: Player2 Player1: 2 of Hearts, Player 2: 2 of Spades Winner: Player 1 This is worth a maximum of 5 points
The consequence of this is that you can manipulate the audio using good old fashioned ints. Write a program that takes in "digital audio" from a text file consisting of ints (one per line). Your program needs to make the music quieter, so you need to divide the volume in "half" and write it to another text file. (the input file should be input.txt, and the output should be output.txt) You also need to write another tool which attempts to double the sampling rate of the audio. To do this, it needs to create virtual samples taking a best guess as to which volume intensity would occur between two. For instance if the volume is -1000 and in the next sample the volume is 0, the sample that would be between them would probably be -500. You should then write the resampled audio to output.txt. The input file should be input.txt, and the formats should match that of the first part of this. This assignment is worth a maximum of 5 points.
last
updated on 5/10/04
Copyright (C) 2004 Jim Casaburi |