Intro to CS
Creative Task #1
Parameters:
- Minimum of 10 lines of code
- draw a cohesive picture
- 4 shapes
- gradient
Below are examples of projects that got full credit
Complete all the methods below. When you are done, copy and paste the testmethods.v5.1 into your class and run it to see if you have any obvious errors. The above code does not guarantee you a 100 but will help catch most of the common errors that students make.
Note: You may not use any external libraries (like Java.Arrays etc )or import any code. Everything can be done with just loops and variables.
int sumEveryN(int[] nums, int n)
Description:This method returns the sum of every n elements of nums ..
| Method Call | return value/output |
| sumEveryN( {1 , 2 , 3 , 4 }, 2 ) | 4( ie 1 +3) |
| sumEveryN( {13 , 42, 15, 33 , 44 , 16 , 52} ,3) | 98 ( ie 13 + 33+ 52) |
String[] doubleArr(String[] strs)
Description: This method returns a new version of strs in which each element now appears twice. This can be done with a for-each loop, which I believe is easier and more intuitive.
| Method Call | return value/output |
| doubleArr( {“a”,”b”,”c”} ) | {“a”,”a”,”b”,”b”, “c” , “c”} |
| doubleArr( {“math”,”ware”,”house”,”.com” }) | {“math”,”math”,”ware”,”ware”,”house”,”house”,”.com”, “.com”} |
int indexOf5(int[] nums )
Description:This returns the index of the first occurrence element 5 or -1 if 5 does not appear anywhere in the array.
| Method Call | return value/output |
| indexOf5( { 2 , 3 , 5 , 4 } ) | 2 |
| indexOf5( { 2 , 3 , 5 , 4, 5 } ) | 2 |
| indexOf5( { 2 , 3 ,7 , 4, 3, } ) | -1 |
More Sample calls and return vals
int indexOf(int[] nums, int num)
Description: This method returns the index value of the first appearance of num or -1 if num is not an element of nums .
| Method Call | return value/output |
| indexOf( {6,4 ,7,3, 4 }, 4) | 1 |
| indexOf( {6,4 7 ,3,2,7}, 7) | 2 |
| indexOf( {6,4 ,2,3}, 22) | -1 |
int[] randos(int start, int end, int howMany)
Description: This method returns an array of random numbers between [start,end] . Note make sure that each element in the new array attempts to make a new random int. Use Math.random() , do not use any other mechanism for finding a random number.
double meanBetween(int[] nums, int min, int max)
Description: This method returns the mean of nums ; however, this method only counts values within the range (min,max) as shown in the examples below:
int secondSmallest(int[] nums )
Description: This method returns the element of nums with the second smallest value.
Note: You may not modify the input array. For instance, you may not put nums in order, which would be bad because you were not asked to modify the array.
@precondition: nums.length >= 2
Note: You will lose credit if you use a constant to represent the smallest or second smallest number. See pseudocode
| Method Call | return value/output |
| secondSmallest( { 2 , 18 , 22, 4 , 6 } ) | 4 |
| secondSmallest( { 3 , 7 , 15 , 1 ,101} ) | 3 |
boolean isPalindromic(int[] nums)
Description:This method returns true if the elements of nums are a palindrome.
| Method Call | return value/output |
| isPalindromic(( { 5 , 2, 7 , 2 , 5} ) | true |
| isPalindromic( { 5 , 2, 7 , 3 , 5} )) | false |
| isPalindromic(( { 1 , 2, 1} ) | true |
Old versions:
Exercises for String 1 and Array 1 (no loops)
When you are done, you can copy and past the score() method below into your class. It will test some (but, by no means all) of the things that your code should do
Create a class called StrArr1 and add each method below into it.

For the absVals() method below use the Math.abs() Java method.
For the randos1to10() method below use the Math.random() Java method. Create a new array to store random integers. Each integer should be [1,10]
It is very rare that I recommend anyone skip from the Intro class, the easiest CS class, to SUPA, the hardest CS class , without the foundation that we build in Computer Science II.
The path to skipping
If you really want to try to skip CS II, the path would be to complete the online component of CS II curriculum during the school year and to then sit down with me for an interview. If I am satisfied that you are ready to skip CS II, I will then make the recommendation.
Much, though not all, of the CS II curriculum is online and so can be completed at a student’s convenience.
Please know, that most of the students who have followed this path and who found the Intro to CS class too easy and who then skipped into SUPA have ended up regretting this and, more often than not, they have had to drop the SUPA class.
Ask yourself– Would you skip Calculus I and instead jump right to Calculus II?
Probably not.
And it’s not much different here; while it has been done, for the most part it has only been successfully pulled off by students who are “hardcore” programmers and who have voluminous experience coding outside the classroom. Kids who have made their own apps and learned how to do real programming on their own.
Now, if that describes you and you have made real apps that you can show, then maybe this is the right move, but otherwise, this jump almost never is.
So, what students should do is this – Have your guidance counsellor sign you up for CS II for next year. If you complete the online part of the CS II curriculum, by June, then we can sit down and I will have an assessment of your readiness to make this radical jump.
Normally we dedicate an entire quarter to a project. We will instead be dedicating about 2/3 of the quarter.
The parameters are similar but not quite so grand in scope. To get an A, you must create a complex web product . This could be a single interactive application or multiple pages . Simple ideas to get to that point include:
Ways to add complexity:
Everybody must use git and have at least 20 commits over the span of the rest of the quarter.
Examples of finished product and grades:
Mr Morris, I just want to pass.
Phaser
http://phaser.io/learn/ ( Where you should start)
Prior Projects: https://mrmonline.org/supa-2019-games/
Deliverables:
I have been asked “How many examples should I have”?
And there is no one answer. You should convey the “major important” aspects. Absolute bare minimum is 5 code examples but there is no need to kill us with redundant code that only has small changes.
|
1 2 |
$ git config --global user.name "John Doe" $ git config --global user.email johndoe@example.com |
Create a new text file and add the code below. Then rename the file so that is a batch file. (ie. that its file extension is “.bat” instead of .txt) .
|
1 2 3 |
cmd.exe /k "cd C:\Users\path\to\websites\UniserverZ\www\ & git status" pause > nul |