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 void method fill
that takes an array of
int
s and an int
that fills every position
of the the given array with the given number. I.e. it changes the
values in the array passed in.
Write a method letterGrade
that takes a
double
representing a score on a test as a percentage
(represented by a number from 0.0 to 1.0 where 1.0 is 100%). Return
a String
consisting of a single-letter grade (no pluses or minuses) on the
traditional grading scale where 90% and above is an A, 80% and above
(but less than 90%) is a B, and so on, down to anything below 60% is
an F.
Write a method countOddNeighbors
that takes an array of
int
s and returns a count of the number of elements in
the array that are odd and their neighbor at the next larger
index is also odd.
Write a method totalOddNumbers
that takes an array of
int
s and returns the sum of all the odd values in the
array.
Write a method maxValue
that takes an array of
int
s and returns the maximum value found in the array.
You can assume the array is at least one element long.
Write a method firstLetters
that takes an array of
String
s and returns a single String
consisting of all the first letters of the elements of the array
joined together.
Write a method checkDigit
that takes two arrays of
int
of the same length. The first array are the
“weights” that will be used as described in a moment. The second
array holds the individual digits of a number. (For instance, the
number 1234 would be represented by the array
{ 1, 2, 3, 4}
.
This method should return a single int
computed by
multiplying each element of the weights array by the corresponding
element of the digits array, summing all those values, and then
extracting the last digit of the resulting sum. For instance if the
weights were { 5, 8, 1 }
and the digits
{ 5, 9, 6 }
the sum is 25 + 72 + 6 = 103 and the final
digit is 3 so the method would return 3.
Write a method longestRun
that takes an array of
int
s and returns the length of the longest run of the
same value is consecutive positions within the array. For instance
in the array { 1, 2, 1, 3, 2, 2, 2, 3, 3 }
the length
of the longest run is 3, the three 2s starting at index 4.
Write a method numDigits
that takes an
int
and returns the number of digits in its decimal
representation.
Write a method maxDigits
that takes an array of
int
s and returns the number of digits in the largest
value in the array.
Write a void method bubbleSort
that sorts an an array
of int
s in place using the following algorithm: Make as
many passes over the array as the array’s length and on each pass
start at the beginning of the array and compare each element with
the next element in the array and swap them if they are out of
order. For example, if given the array
{ 10, 3, 11, 4 }
, on the first pass you’d first compare
10 and 3 and swap them since 10 > 3. Then you’d compare 10 (now in
the second position) with 11 and leave them in place. Then you’d
compare 11 with 4 and swap them, giving you this:
{ 3, 10, 4, 11 }
. On the next pass you’d start again at
the beginning and end up swapping 10 and 4, leaving the array
sorted.
This is a simple sorting algorithm that gets its name from the way the higher values in the list “bubble up” to the top on successive passes. This is also a notably inefficient sorting algorithm but there are a few optimizations that you can make to reduce the number of passes you have to make in some cases and to eliminate some needless comparisons. If you get the tests passing, you may want to experiment with those if you have extra time.
Usual drill. Write as many methods as you can. Note that some of these are designed to be hard enough to justify raising 3s to 4s. But if you’re aiming to increase to a 3 don’t worry if you can’t get them all. On the other hand, some of these are really quite easy—don’t psych yourself out by thinking it needs to be harder; they might really be that easy. (Back to Fall Final page.)
All topics: