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.
Write a method that takes two numbers and returns the midpoint between them. For instance the midpoint between 6.0 and 10.0, the midpoint is 8.0.
If you remember the Pythagorean theorem, you know that the length of the hypotenuse of a right triangle is the square root of the sum of the squares of the two other sides. Write a method that takes the lengths of the two legs of a right triangle and returns the length of its hypotenuse.
The perimeter of a square is four times the length of one side. Write a method that takes the length of the side of a square as its argument and returns the perimeter of the square.
The perimeter of a rectangle is two times the sum of its width and height. Write a method that takes the width and height of a rectangle as its arguments and returns its perimeter of the rectangle.
The area of a square is the square of the length of one side. Write a method that takes the length of one side of a square as its argument and returns the area of the square.
The area of a rectangle is its width times its height. Write a method that takes the width and height of a rectangle as arguments and returns the area of the rectangle.
The area of a triangle is half the base time the height. Write a method that takes the length of the base and the height of a triangle as arguments and return the area of the triangle.
The area of a trapezoid is half the sum of the bases (the two parallel sides) times the height. Write a method that takes the lengths of the two bases of a trapezoid and its height as arguments and returns the area of the trapezoid.
The area of a circle is π times the square of the circle’s radius. Write a method that takes the radius of a circle as an argument and returns the area of the circle.
The surface area of a sphere is four times the area of a circle with the same radius as the sphere. Write a method that takes the radius of a sphere as its argument and returns the surface area of the sphere.
The volume of a sphere is 4/3 times π times the radius cubed. Write a method that takes the radius of a sphere as its argument and returns the volume of the sphere.
The circumference of a circle is 2πr. Write a a method that takes the radius of a circle as its argument and returns the circumference of the circle.
The curved surface area of a cylinder (i.e. the outside excluding the top and bottom) is the circumference of its base circle times its height. Write a method takes the radius and height of a cylinder as arguments and returns the curved surface area of the cylinder.
The total surface area of a cylinder is the curved surface area plus the areas of the top and bottom. Write a method that takes the radius and height of a cylinder as arguments and returns the total surface area of the cylinder.
The volume of a cylinder is the area of the base circle times the height. Write a method that takes the radius and height of a cylinder as arguments and returns the total volume of the cylinder.
The curved surface area of a cone (i.e. the outside excluding the circular base) is π times the radius of the base times the cone’s slant height. Write a method that takes the radius and slant height of a cone as arguments and returns the cone’s curved surface area.
The total surface area of a cone is its curved surface area plus the area of its circular base. Write a method that takes the radius and slant height of a cone as arguments and returns the cone’s total surface area.
The total surface area of a cone can also be computed from its base radius and height by computing its slant height using the Pythagorean theorem. (The slant height is the length of the hypotenuse of a right triangle formed by a radius of the cone’s base and its height.) Write a method that takes the radius and the height (not the slant height) of a cone as arguments and returns the cone’s total surface area.
The volume of cone is the area of its circular base time a third of its height. Write a method that takes the radius of a cone’s base and its height as arguments and returns the volume of the cone.
This is a test of writing methods. It may seem like a lot of math but remember that this is not about you doing math but you making the computer do it for you.
All the arguments and return types of these methods will be
double
. You’ll probably want to use the
Math
methods discussed in Unit √2 such as
Math.sqrt
and
Math.pow
. You can also use the variable
Math.PI
to get a good approximation of π.
One of the key elements of this assignment is that many of the
methods you will be asked to write require you to implement formulas
expressed in terms of other formulas you will have implemented.
Remember that just like you can call Math.sqrt
you can
also call a method that you’ve defined.
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.