Welcome to AP Computer Science A. If you are a student in the class, the first thing you need to do (and which we should have done in class) is set up your GitHub account.
Once you have a GitHub account, click “Log in to GitHub” below to proceed.
If you don’t have a GitHub account yet, please create one and then log in here for further instructions.
Congratulations! You have successfully connected this app to GitHub. However you are not yet a member of the GitHub organization for this class, something Mr. Seibel needs to set up for you.
This is your GitHub profile URL:
Click the clipboard icon to copy it and then submit it at this form so he can add you.
Congratulations! You have successfully connected this app to GitHub. And it looks like you have an invitation to join the GitHub organization for this class. You need to accept that invitation before you can proceed. The invite should be sent to whatever email you used when you created your GitHub account.
I see you are logged into GitHub and a member of the berkeley-high-cs GitHub organization. However there seems to have been some problem finishing the setup for your account. Please let Mr. Seibel know.
This is a tool for the AP Computer Science A class at Berkeley High School. It is intended to provide a simple environment for experimenting with Javascript without all the complexities of a full development environment such as ReplIt or Glitch which we may use later in the year.
It is also designed to take advantage of the browser’s ability to run Javascript natively. It does not need access to a server to run code making in extremely responsive even if the Wifi is flaking out.
Finally, under the covers it is saving work to a GitHub repository in a very simplified workflow that does not depend on immediately learning any git commands. Code written in this environment for each assignment is saved to a directory and branch specific to that assignment each time it is saved. Thus when the assignment is done, it is easy to go to GitHub and create a PR containing just the work on that assignment which can then be commented on and worked on further before it is turned in and merged to main.
You're all set! You don't need to worry about this yet but we have successfully created a GitHub repository for your work:
You can get to it any time by clicking on your GitHub username at the top-right of the screen.
As you probably leaned in 9th grade physics, force equals mass time
acceleration, or the famous F = ma. Write a function that
takes two double
arguments representing a mass in kg
and and acceleration in m/s2 and returns the force in
Newtons (kg * m / s2) as a double
.
Einstein’s famous equation E = mc2 tells us that
the theoretical amount energy we can obtain from a given mass. Where
m is a measure of mass and c is the speed of light.
Write a function that takes a single double
argument
representing a mass in kg and returns the equivalent energy as a
double
according to this equation. You can use the
variable C
that has already been defined for you as the
value of the speed of light.
The distance between two numbers on the number line is the absolute
value of their difference. Write a method that takes two
double
arguments and returns the distance between them
as a double
The distance between two points in 2d-space is normally obtained
with our old friend the Pythagorean theorem. In other words it is
sqare root of the sum of the squares of distances between the two
points on the x- and y-axes. Write a method that takes four
double
arguments representing two points in 2d space as
the x and y of the first point followed by the x and y of the second
point and returns a double
representing the distance
between the two points.
An alternate measure of distance between two point in 2d-space is
defined as the sum of the distance along the x-axis and the distance
along the y-axis. It is called the Manhattan Distance or Taxi Cab
Distance because the streets in Manhattan are famously laid out in a
grid so you can’t move diagonally; this measure describes the
distance you would travel moving between two points in Manhattan.
Write a method that takes four double
arguments
representing two points as in the previous
distance2d
method and returns a
double
representing the Manhattan Distance between the
two points.
Write a method that takes a single String
argument and
returns a new, more excited String
consisting of the
argument followed by the exclamation points.
Write a method that takes a single String
argument and
returns a new String
consisting of the argument
repeated with a space between the two repetitions.
Write a method that takes a single String
argument and
returns a new String
consisting of the argument
repeated with a space between the two repetitions followed by three
exclamation points.
Write a method that takes two double
arguments
representing the length of a space and the length of an item that
you want to place in the space and returns a
double
represesting where to position the item so that
it’s two ends are the same distance from the ends of the space. You
can assume both arguments are positive and the second argument is
less than the first.
For instance, to center a six foot rug in a ten-foot room, we need to position one edge two feet from one wall so the other edge will be two feet from the other wall. In other words, we want to know half of the space left over when we subtract the length of the item from length of the space.
Write a method that takes no arguments and returns a random value in the range from 0.0 to 2.0 (inclusive and exclusive). There are no tests for this method since its output is inherently unpredictable.
Write a method that takes three double
arguments: a
value in the range 0.0-2.0 (i.e. like one returned by the
randomCoordinate
method), a starting value, and a
length and returns a double
value so the new value is
in the range from start to start + length. For example if the first
argument is 0.0 then this method should return start value; if the
coordinate is 2.0 it should return start + length; and if the
coordinate is 1.0, it would return the value that is the start +
half the length.
This is a test of writing methods. You may need to use the methods
from Math
that you learned about in this unit. Also for
one problem you will need to use the constant C
which
is defined in the starter code and represents the speed of light in
meters per second. Because it’s in the same class as the rest of
your code you can refer to it as just C
. When possible,
you should write your methods in terms of other method you have
written here.
Pro tip: when you click one of the method buttons, the name of the method is copied to your clipboard so you can paste it into your code, saving typing and avoiding spelling errors. Finally, click the black triangle at the start of these instructions to collapse them and have more room to code.