Let's Play Geo Guessr

Contest from 2015

Contest Rules

Adding Audio In Java

Regions in Netbeans

Text Based Java Game

Moon Landing

https://tmc.mooc.fi/mooc/

Notes Are Here



Competition Stuff
Start Here

Welcome to Comp Sci 40S.

Goal of the Course:
The emphasis in computer science courses is on students learning to solve problems, accomplish tasks, and express creativity, both individually and collaboratively. Students will learn programming techniques and the syntax of one or more programming languages. More importantly, students will learn to adapt to changes in programming languages and learn new languages as they are developed.

I would like to use:
Unity
Corona Labs (App Development)
Python
C++

Assessment:
Projects 35%
Tests 35 %
Exam 30 %


We will start with Python.
Check IO

Here are some Python Resources:
Python Resources


If you would like to practice Python Click here:
Practice Python


Problem of the day


Isaac and Albert were excitedly describing the result of the Third Annual International Science Fair Extravaganza in Sweden. There were three contestants, Louis, Rene, and Johannes. Isaac reported that Louis won the fair, while Rene came in second. Albert, on the other hand, reported that Johannes won the fair, while Louis came in second.
In fact, neither Isaac nor Albert had given a correct report of the results of the science fair. Each of them had given one correct statement and one false statement. What was the actual placing of the three contestants?

January 21st

If you are done the assignment from January 18th, I would like you to go to this site:

Project Euler

Create an account, and then attempt to solve one of the projects. Good luck!

January 18th


In class I would like you to calculate a "Change Calculator" for a Point of Sale cash register. The program will ask for a subtotal. Then it will calculate the following:
  • Input subtotal from the User
  • Output the Taxes (13%)
  • Output the Total
  • Input the amount paid
  • Output the amount of Nickels, Dimes, Quarters, Loonies, Twonies, Fives, Tens and Twenties, owed to the user.

January 4th

Research information on a programming language that is new to you, and learn the syntax independently by creating a new program or recreating an existing program written in a different language.

eg languages:

  • Basic
  • Visual Basic
  • C++
  • Java
  • Html

Here is a link to a list of languages:
Comp Sci Languages

December 14th

Loan Payment

If you take out a loan for a fixed amount of time, what should your payments be? The answer is complicated by the fact that you are charged interest, so you can't just divide the amount of the loan to be repaid over the amount of time. Fortunately, there's a formula for calculating the payment on a loan. Suppose you have a loan for N months, and the amount you have loaned is P dollars. Also, assume that the interest rate is r (as a decimal, i.e., 5 % would be r = 0.05). Then the monthly payment on your loan is:

P * r * (1+r) N / ( (1+r)N – 1)


Write a program that accepts three values, P, N and r, and then outputs the amount to be paid each month. The first two values are integers (no decimal point) greater than zero, and the last is a decimal number greater than 0 and less than 1. Input Your program should accept three quantities on separate lines of input: first the initial amount loaned (P), then the number of months of the loan (N), and then the interest rate as a decimal (r).

Output

Your program should output the integers payment in this format: “The monthly payment is $X. “ where X is a decimal number. Do not worry about rounding the output value.

Input:
20000
60
0.069

Output:
The monthly payment is $1405.657672350561


December 10th

We will work with arrays and make a 10 by 10 grid of buttons. With an end goal of making the game ConnectFour.

Here is a link to creating a button at runtime in C#

Runtime Button




November 24th


Here is my pseudo code for the Add and Delete Name Project

Console.WriteLine Ask the user what they would like to do? Add or Delete

if Add
Who would you like to add
StreamWriter sw = File.AppendText(" The path of the file you are adding to");
sw.WritLine(Console.ReadLine());
sw.close();

Else Delete
Who do you want to delete?
store the name in a string

We will use a list to go and get all the names in the file.
List<string> names = new List<string>();

System.IO.StreamReader fileReader = new System.io.streamReader(Path of File);
string Line = fileReader.Readline();

Go into the loop while this condition is true.
While (Line != null)
{
If it is not the name we want to delete add it to our list.
if (line != The Name We want to delete)
{
names.add(line);
}
Go get the next line from the file.
line.fileReader.Readline();
}close the loop
fileReader.close();

Now we need to write our new list to the file
forEach (string thisName in names)
{
fileWriter.WriteLine(thisName);
}
fileWriter.close();

November 17th


Reminder we will write a test tomorrow on Loops and If statements in C#.


Our next assignment we will be creating a program that will read and write to a file. We will keep a database of names is a text file. The user will have an option to do the following with Our program:

1- Add a name to the textfile.
2-Delete a name from the text file.(If the name does not exist have a message show a warning)


Here is some example code how to write to an existing file:

addToFile.PNG
==

==

November 6th

Goodmorning,

First I would like you to finish the assignment from November 5th. Be sure to show me, as it is for marks.
Next we are going to learn how to write to a file. Here is a snippet from my code:
WriteToFileTwo.PNG

After your program runs it should look similar to the image below:


writetoFile.PNG

November 5th

I would like you to do the following on your own:
Create a new C# project
Have it read from a file in your z Drive. The text file should have the line "Hey how are you?"
Then using Console.WriteLine have the program output to the screen the words, one per line. eg:
Hey
how
are
you?

November 4th

You are responsible for determining the medal winners for your school's track meet. You are given a list of finish times for each runner, and need to determine the gold, silver and bronze medallists. The times appear in the order they come in from different heats, so they are not in order.

Input
Each line of input consists of the results from a single event. The first integer in the line, n, gives the number of competitors in the event. The next n floating point values give the race times for each competitor, in seconds and fractions of a second. There are always at least three competitors per race. You are also guaranteed that each finishing time is unique.
Output
For each race, list the three medal-winning times as follows: "Race X GOLD: nnn.nn SILVER: nnn.nn BRONZE: nnn.nn" Races should be numbered starting at 1. Do not output any blank lines between the race results. Output the same number of decimal places as in the input data.
RaceSample.PNG

RedLineC#.PNG

November 3rd

Problem 2 – Multiply perfect numbers A number n is said to be multiply perfect if the sum of all the divisors of n is equal to k*n for some k ≥1 (a divisor of n is a number d such that d divides n). For instance, the number 120 is a multiply perfect number since the divisors of 120 are 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60 and 120, and the sum of these numbers is 360 which is 3 times 120. Write a program that takes a number n and outputs either "not multiply perfect" if n is not multiply perfect or the number k if n is multply perfect and the sum of its divisors is k*n.

Input:
The input file consists of several positive numbers, followed by the number zero. Each number will be on its own line. The number zero indicates that you are at the end of the input: do not proces the number of zero as input. Simply terminate when zero is reached.


Sample Input
Sample Output
6
2
7
Not Perfect
120
3
0


October 29th

All period Day. Here is the plan for the day:
Report to class 212 at 8:30. We will work for an hour, then take a bus to the U of W.
We will attend a lecture for 1 hour.
Then we will get a 1 hour tour of the University.
Then we will have lunch then head back to school.

October 28th


Good morning class, today we will be working in C# again. So we need to start by opening "VS Express for Desktop" and creating a new project in C#.

Here is the project we will be working on today and tomorrow.

The balance game is played with two players and an old-fashioned balance scale, the kind used to measure weight. Players take turns placing rocks on their side of the balance while the other player’s back is turned, trying to guess how heavy a rock they need to even out the scales. Every time a player balances the scales, they receive a point. The player with the highest score after all the rocks are played wins. For this computer simulation of the balance game, you are given a sequence of integers indicating the weight of the rock being played, starting with player 1, followed by player 2, and then alternating between the two players. The signs of the numbers are alternating too; all of player 1’s numbers are positive, and all of player 2’s are negative (the magnitude of the number is the weight of their rock). Every time the total weights played on the two sides are equal, the player whose rock was most recently played scores a point.


Input The first line of the input has a single integer n, which is the number of rocks to play. The next n lines each contain one integer representing the weight of one rock, starting with a positive value for player 1 and alternating with negative values for player 2.

Output Print the total number of times the scales were balanced for each player (their score).

October 27th


Today we will be starting C#. To start I would like you to try and complete yesterday's loop in C#. C# is on your desktop under VS for Desktop, and be sure to open a Windows App.

http://www.tutorialspoint.com/csharp/csharp_strings.htm


October 26th


For this question, write a program that outputs the volume of a series of twenty boxes. These boxes each have a length (L), height (H) and width (W) that are integers, and satisfy H = L + 1 and W = H + 1. The lengths of the boxes go from L = 1 to L = 20. So the smallest box has dimensions L = 1, H = 2, W=3 and a volume of 6. The last box has dimensions L=20, H = 21 and W = 22 and a volume of 9,240. Input This problem does not have any input. The program will begin, write the output, and then quit. Output Output twenty integer outputs, one on each line, representing the volumes of the twenty boxes with lengths from 1 to 20.


October 21st

A la Mode Given a collection of numerical values, the mode is the value that appears most often. For instance, the mode of {1, 3 ,1, 5, 5, 7, 0, -1, 1} is 1 because it appears three times in the data. Write a program that reads in lists of integers and finds the mode. In all the data sets, there is a unique mode: the value that appears most appears more times than every other value in the collection. Input Each list of integers is given on its own line. The line contains one or more integers, each separated from the next integer by a single space.

Output For each input, first output “CASE x: “, where x is an integer starting at 1.

Then output the mode.


October 20th

XYZ Given three numbers x, y and z, where x is a single digit number (1-9), is it true that the number x appears y times in x*y*z? For instance, if x = 7, y = 9 and z =12345679, then x*y*z = 777777777, so the answer is yes, since the number 7 appears 9 times in the answer. For x=3, y=4 and z=278, the answer is no, since x*y*z = 3336, and the number 3 only appears 3 times while y=4.

Write a program that takes the three integers x, y and z and prints out the product of the three numbers and then answers whether x*y*z has y appearances of the number x. Input Each case is on its own line. The three integers on the line are in the order x, y, z. In between the numbers is a single space. The number x satisfies 1 ≤ x ≤ 9, while y and z satisfy 1 ≤ y, z ≤ 231-1 and x*y*z ≤ 231-1. The final line of input is 0 0 0. Do not process this line of input.

Output For each case, start the input with "CASE x: " where x is an integer starting at 1, then write the product x*y*z and either the word "yes" or "no", depending on whether x appears y times in x*y*z* or not.




October 19th

While setting up a PIN for a bank account, you are told "only digits 1-8 are allowed and the PIN must have exactly 5 digits". How many PINs of length 5 are there? Write a program that prints the number of PINs of length 1 to 5 if there are 8 different possibilities for each character in the PIN. For length 1, there are 8 possibilities (any digit from 1-8) and for length 2 there are 64 possibilities (8 possibilities for the first digit and 8 possibilities for the second digit).

Input
This problem does not have any input. The program will begin, write the output, and then quit.

Output
Output ten integer outputs, one on each line, representing the number of possible PINs of length 1-10.



October 16th

Here is the plan for the day.

1- write a program in https://repl.it/languages/python3 Your program will input a word as a string. Your program will return true, if the word is a palindrome, it will return false for all other words. A Palidrome is a word that is written the same forward and backwards. An example of a Palindrome is racecar.

Once you are done call my over for a screen check.

Next make sure you have completed the following assignments:
1- The program we wrote on Wednesday, that inputs a word as a string and spells it backwards.
2-Mole Masher
3-The program on the whiteboard that checks for positive, odd, multiples of 6 and prime numbers.
4- CheckIO you should be up to "End of Other"
5- You can try making Space invaders on App Inventor 2 Space Invader Tutorial





October 14th

Write a program that will input a string, and then return the string written in reverse.
To input in repl.it use the command x = input("Please enter a word") this will save the word in the variable 'x'. When you are done call Mr.Boughen over.

One you are done, you make work on Mole Masher, the Program on the Whiteboard, Space Invaders.
.




October

Let's try using MIT App Inventor

Here is the tutorial that we will be following: Mole Smash