Welcome to BHS Computer Science. 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. Or you can click “Use anonymously” to play with the environment but you will not be able to save your work or submit assignments. (You can always log in later by clicking the at the top of the page.)
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 BHS Computer Science 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.
This assessment consists of functions you need to write involving numeric expressions. It is a closed book assessment. You should stay on this tab until you are done and there should be no talking. This assessment is about how much you understand. There are no automatic tests but you can use the REPL to test things yourself.
You can move through the questions with the arrows at the upper right
next to the 1 of indicator so if
you're not sure how to write one function move on to another one and
come back if you have time at the end. I want to see how much you do
know. Note: you can also click on
thingsLikeThis
in these instructions and the questions to
copy them to the clipboard to avoid spelling mistakes.
When you are done, please submit a GitHub pull request of the
branch and request me as a reviewer.
Doing this correctly is part of the assessment.
Write a function named itemsLeftOver
that takes two
arguments, a number of people and a number of items, and returns
the number of items that will be left over after you give each
person the maximum number of items you can while giving everyone
the same number of items.
Write a function named areaOfCircle
that takes one
argument, the radius of a circle, and returns the area of the
circle. The formula for the area of a circle with radius
r is πr2. In Javascript you can use
Math.PI
to get a good approximation of π.
Write a function named volumeOfCube
that takes a
single argument specifying the length of one edge of a cube, and
returns the volume of the cube.
Write a function named populationGrowth
that takes
two numeric arguments, the current size of a population and a
growth rate expressed as a fraction the population will grow in
a day. The function should return the amount by which the
population will grow in one day. For example, if the population
was initially 100 and the growth rate was 0.25, it would grow by
25 members.
Write a function named earnedRunAverage
that takes
two arguments, the number of “earned runs” a baseball pitcher
has given up and the number of innings that pitcher has pitched.
The function should return the pitcher’s Earned Run Average
(ERA) which is defined as the average number of earned runs per
inning pitched multiplied by 9.
Write a function named valueOfJewels
that takes
four arguments, a number of diamonds, a number of emeralds, the
value of one diamond in gold pieces, and the value of one
emerald in gold pieces. The function should return the value in
gold pieces of the given number of diamonds and emeralds. In
other words multiply the number of each type of jewel by the
value of that kind of jewel and sum the products.
Write a function named payWithOvertime
that takes
three numeric arguments, a number of hours someone worked, their
normal hourly rate, and their overtime rate. The function should
return how much they are paid for the hours worked assuming that
they are paid their normal rate for the first eight hours and
their overtime rate for any hours beyond that.
Write a function named firstClassPostage
that takes
one argument, the weight in ounces of a letter. It should return
the postage needed, in cents, to mail the letter given that
anything up the first ounce costs 60 cents and each additional
ounce, or fractional ounce, costs 24 cents. A function that will
be useful is Math.ceil
which returns the smallest
integer greater than or equal to its single argument. For
instance, Math.ceil(2.3)
is 3.
Write a function named weightOnJupiter
that takes a
single argument, the weight of a person in kilograms on Earth,
and returns the weight of that same person on Jupiter.
Note that weights on other planets are computed by multiplying
the Earth weight by the ratio of the other planet’s gravity to
Earth’s gravity. For instance, if there was a planet whose
gravity was exactly twice Earth’s, then someone would weight
exactly twice as much on that planet as on Earth. Two useful
constants defined in the starter code for you are
JUPITER_GRAVITY
and EARTH_GRAVITY
Write a function named gravity
that takes three
numeric arguments, the first two are the masses of two bodies
(such as planets) and the third is the distance between the two
objects. It should return the gravitational force attracting the
two bodies which is computed as the product of the bodies’
masses divided by the square of the distance between them, all
multiplied by the universal gravitational constant which is
defined for you in the starter code as the constant
G
.