Thursday, December 8, 2011

Challenge 031

the decimal notation of (238, 9, 63) is equal to the hexadecimal of 0E14FF. 

To start, hexadecimal numbers have a base of 16. when a number is in decimal form, you are to divide each number that you are given by a denominator of 16.

The first number is 14 so it is 14/16. Since the number is less than 1, you add 0 to the beginning of the answer because it doesnt effect the answer. 14/16= 0+ 14/16. We only look at the numerator when converting. Since the numerator is in between 10 and 15, it takes a value between A-F (For example, 10=A 11=B 12=C 13=D 14=E 15=F). So, the first value of the hexadecimal code is 0 because we added 0 to 14/16 and the second character would be E because 14 corresponds to it.

Next, we divide 20/16 which is equal to 1 and 1/4. We take the number left of the decimal first so the next value of the hexadecimal is 1. Since we use a base of 16, 1/4 equals 4/16. Value 0-9 equal themselves when converted (For Example, 0=0 1=1 2=2...9=9). so the next value of the code is 4.

Lastly, we divide 255/16 and get 15 and 15/16. since the number left of the decimal is between 10 and 15, it takes a letter value which happens to be F. Then we take the value to the right of the decimal which is 15/16 and because it is between 10 and 15, it takes a letter value which happens to be F.

So, the code converts to 0E14FF.

Wednesday, November 2, 2011

Challenge 029

When the specific code is entered into the compiler, your result is as follows:

******
******
******
******
******

The for loop has three stages: initialization (it's executed once, as the loop begins).
termination (expression evaluates to false, the loop then terminates).
increment (what is produced after each cycle through the loop).

There are five lines of *'s because we set k=1 and tell the loop to produce the output of *'s until the statement for (int k = 1; k <= 5; k++) is false. This happens to be 5 times since there are only 5 lines.
As for the number of *'s in a line, the for loop tells i to create the loop. Since we set i=1, the for loop says to print out an * until the statement for (int i = 1; i <=6; i++) is false. This happens when the i value reaches 7. Since on 7 it is false, it terminates and produce 6 *'s.

The way the for loop works is first the compiler will verify that the for loop for k is true for k=1, then it will go down and verify that the for loop for i is true for i=1. Because of the System.out.println() , it skips a line and goes on to the next line. It then goes back up to the for loop for k because of the k++ in the code. This means thats k = k+1. So now it produces the second line of stars because the loop is true. After this, it goes down to the for loop for i++ so it produces 2 stars on the lines. This loop continues until k reaches 6 and i reaches 7

Challenge 028

import java.util.Scanner;

public class GradeOMatic
{
public static void main(String[] args)
{
Scanner scanUserInput = new Scanner(System.in);
System.out.print("Grade Received (%): ");
int n = scanUserInput.nextInt();
if (n >= 70)
if (n >= 80)
if (n >= 90)
System.out.println("Excellent!");
else
System.out.println("Good!");
else
System.out.println("Average.");
else
System.out.println("You Stink!"); //just kidding it's System.out.println("Bad Times!");
}
}
This code displays the appropriate comment when percentage scores are entered.

(With help from the code in Challenge026)

Challenge 027

Location hotSpot = new Location(4 , 7)

Tuesday, November 1, 2011

Challenge 026

The code goes wrong when you type in odd numbers when the program is ran. The compiler tells you that any positive odd number is not positive. Another problem that Karl has encountered is how the compiler wont run the program and provide him with an answer when he enters a negative number.

The problem in the code is in his statement: if (n % 2 == 0)
This is incorrect because this is telling the compiler to only perform the task if the remainder of n/2 is 0. This makes sense because any even number divided by 2 will result in an int. He could fix this solution by eliminating the faulty statement.

Thursday, October 27, 2011

Challenge 025

An instance variable is defined in a class in which each object has their own separate copy. All instances are within a constructor function and can be assigned a unique value without modifying the values of other copies of the instance variable.

In this class, there are three instance variables. These three specific instance variables are name, gender, and yearOfBirth. Each of these instance variables contain a copy value.

Two addition instance variables for this code could be weight and shoe size.
The code for these are as follows:

public class Person
{

private String name;
private String gender;
private int yearOfBirth;
private int weight;
private int shoeSize;


public Person()
{
name = "unknown";
gender = "other";
yearOfBirth =0;
weight = 0;
shoeSize = 0;
}

public Person(String n, String g, int year, int weight, int shoeSize)
{
name = n;
gender = g;
yearOfBirth = year;
weight = pounds;
shoeSize = inches;

}


//BOOM!

Challenge 024

The statement in question should be inserted right before the last curly brace on the code. However, the statement in question should read Person person1 = new Person(name, "female", 2000);. She skipped the statement all together. when you aren't sure of the name, you should input the code name because in the previous section of code, it tells us that name = "unknown". The gender "female" must be inserted next because the code must be written in order (name, gender, 2000) because the public Person(String n, String g, int year). Female is also written in quotes because it is a string. Lastly, 2000 is inserted as an int value because she defines person1 as born in the year 2000. This will help Lauren define person1 without error

Wednesday, October 26, 2011

Challenge 023

Constructors are awesome!!!

Constructors give you the option to alter the bug within certain parameters. You can click on the frid to construct or manipulate and actor (bug).

info.gridworld.actor.Bug(java.awt.Color) is a constructor. When clicking on this constructor inside the world, you are able to change the parameters of the bug. For example, you are able to change the color of the bug. You are also able to alter the bug by clicking it and getting a list of constructors. From here, you can move the bug to a specific coordinate location on the grid, you can alter the color, turn the bug, etc.

Since you are able to click on each individual box in the grid, it leads me to assume that there are as many constructors as there are squares in the grid?

Tuesday, October 25, 2011

Challenge 022

import info.gridworld.actor.ActorWorld; //First you need to import all the gridowrld files
import info.gridworld.grid.Grid;
import java.awt.Color;
import info.gridworld.actor.Bug;
import info.gridworld.grid.Location;

public class GWTest {
public static void main(String[] args) {
ActorWorld Overgrown = new ActorWorld(); //This names and creates the world in which the bugs are a part of
Bug Yellow = new Bug(Color.YELLOW); // This creates a bug that is yellow
Yellow.setDirection(Location.SOUTHWEST); // This sets the bug to be pointed in the southwest direction
Location Y = new Location(5,4); // This sets the yellow bug to the grid coordinate (5,4)
Overgrown.add(Y, Yellow); // This adds the yellow bug to the grid
Bug Magenta = new Bug(Color.MAGENTA); // This creates a bug that is yellow
Magenta.setDirection(Location.SOUTHEAST); // This sets the bug to be pointed in the southeast direction
Location M = new Location(5,5); // This sets the magenta bug to the grid coordinate (5,5)
Overgrown.add(M, Magenta); // This adds the magenta bug to the grid
Bug Blue = new Bug(Color.BLUE); // This creates a bug that is blue
Blue.setDirection(Location.NORTHEAST); // This sets the bug to be pointed in the northeast direction
Location B = new Location(4,5); // This sets the blue bug to the grid coordinate (4,5)
Overgrown.add(B, Blue); // This adds the blue bug to the grid
Bug Green = new Bug(Color.GREEN); // This creates a bug that is green
Green.setDirection(Location.NORTHWEST); // This sets the bug to be pointed in the northwest direction
Location G = new Location(4,4); // This sets the freen bug to the frid coordinate (4,4)
Overgrown.add(G, Green); // This adds the green bug to the grid
Overgrown.show(); // THis allows you to view the world
}
}

Wednesday, October 12, 2011

Challenge 019

int result = 13 - 3 * 6 / 4 % 3;

This string gives you an output of 12.

you follow order of operations so:

3 * 6 = 18
18 / 4 = 4.5 ; since result is declared an integer, 4.5 is truncated to simply 4
4 / 3 = 1 with a remainder of 1 ; because of the % , this results in a value of 1
13 - 1 = 12

12 is the result and remains an integer.

Monday, October 10, 2011

Challenge 018

(1) double answer = (double) 13/5; will give him an answer of 2.6 because he is calling for the ddt of 13/5 which equals 2.6 because when you divide a double by an int, you get a double value.

(2) double answer = 13 / (double) 5; will give him an answer of 2.6 because we are naming 5 a ddt. When dividing an int by a double, you get a ddt answer.

(3) double answer = 13.0 / 5; will give him an answer of 2.6 because you again are dividing a double by an int, resulting in a double answer. When only 13.0 is stated, the compiler knows that this is intended to be a ddt.

(4) double answer = 13 / 5.0; will give him an answer of 2.6 because you are again dividing an int by a double, resulting in a ddt. When only 5.0 is stated, the compiler knows that this is intended to be a ddt.

(5) double answer = (double) (13/5); will NOT give him an answer of 2.6 because you are taking the quantity (13/5) and then taking the result and making it a double, with a result of 2.0

Challenge 017

All of the follow statements are true.

(A) This statement is true because !A is true and according to Morgan's Law, ! (X && !Y) is the same thing as !B || C . Therefore, !B is true.


(B) This statement is true because it requires only A , B , or C to be true. These are all true because they start off false but are true because of the !.


(C) This statement is true because !( A || B || C) means that they are all true because you distribute the ! within the parenthesis. While only one need to be true, they all are.


(D) This statement is true because after distributing the ! to each variable, all of the variables become true. The && calls for all of the variables to be true, so this statement is true.


(E) This statement is true because either A , B , or C need to be true. !A is true so this statement is true.

Challenge 016

System.out.print("\\* This is not\n a comment *\\");

The output of this statement is:

\* This is not
a comment *\


The \\ is an escape character which basically means that when two back slashes are inserted, only one is outputted when it is in a String[] statement.. The quotation tells the compiler to output the statement within itself. The reason that it is two separate lines is because of the \n . This tells the compiler to move the following characters to the next line.

Challenge 015

I) double x = 14.7;
int y = x;
System.out.print(y);

An error occurs because we name x a DDT (Double data type) and in the next line, we are switching it to an int value when claiming y = x. In order to fix this, we need to change the second line to double y = x to produce the output of 14.7


II) double x = 14.7;
int y = (int) x;
System.out.print(y);

The output produced is 14. we claim x to be a DDT and then in the next line we are saying make the integer value of y equal to the integer value of x. This is basically truncating the 14.7 to produce 14. The ddt is simply canceled due to (int) x;


III) int x = 14;
double y = x;
System.out.print(y);

This set of statements produces a value of 12.0. Since y = x , then y =14. However, it is calling for a ddt which makes it a double. With a double comes a decimal. A zero is added because we already declared the y = 14 so .0 applied.

Friday, October 7, 2011

Challenge 013

When the bug is located in the Northeast corner of a bounded grid and facing North, it... turns 180 degrees(45 degrees at a time) and heads south. While the bug moves, it drops flowers behind it that turn darker and darker each time the bug moves one unit. When it reaches the south east corner, It turns -90 degrees and heads east continuing its behavior. when it reaches the south west corner, it heads north.

The bug continues to drop flowers that darken as the bug moves. The bug never leaves the boarder of the grid and continues traveling in a clockwise motion that is never ending and never gets interfered with.

Challenge012

All of these Statements output a result of 1234.

1) System.out.print(12 * 100 + 34)

This outputs 1234 because it is outputting what is inside the parenthesis. So, 12 * 100 = 1200 1200 + 34 = 1234


2) System.out.print("12" + 34)
The "x" tells the compiler to output the value that is enclosed within the quotations. so the compiler will automatically output 12 as the first value because it is the first listed. Then 34 is the next output because nothing is being added to 34. 12 isnt being added because it has already been outputted because it is within the quotations. so 12 then 34 [1234]


3) System.out.print(12 + "34")
This is similar to the 2nd output. it outputs only 12 because nothing is being added to it because 34 is within the quotations. since 12 is listed first, 12 is output with 34 following. 12 and 34 [1234]

Monday, October 3, 2011

Challenge 011

The reason that this will not compile is because the term static must be inserted after public and before double goFigure (int n). without the term static, goFigure is useless to use.

The output turns out to be 2.0 12. It is asking for the double data type so that explains why it is 2.0. It also says create a space when it say System.out.print(" " + n); and then to add n which we declared was 12. So you have the 2.0 print out and the 12 print out.

The next line tell us that n is equal to the amount of time that 7 goes into into. Keeping in mind that n previous was declared 12, 7 goes into 12 about 1 time with a remainder of 5. n = n % 7; since it call for n being an int earlier, 12/5 is rounded down to 2. It then calls for a double data type which turns it into 2.0.

Therefore, you have 2.0_12.

Sunday, October 2, 2011

Challenge 004

I like how He is not in favor of kids being taught things on an endless basis, but rather play with things and discover on their own. I thought that was worth stating because isnt that what we are doing in this experience?

I myself am not huge on the idea of evolution, but I found this video extremely interesting. I think it is a great idea to get kids involved with learning and ideas early. Playing games as a kid is never boring, and parents will never be disappointed when their child is learning. Its a win win situation. He then goes on to show us how they can use their imaginations by designing their own creature. He is all about "the player's imagination," which I think is great because isn't that how everyone we have seen on TED has came up with their idea? From imagination? You have to start somewhere and I think that an interactive game is a great place to start.

I 100% support Him when he talks about how he wants to focus on long-term thinking and how most of the problems in the world are amplified by short term thinking. I do see that we are now trying to look long-term especially when it comes to the Earth's ozone, atmosphere, and general health. For example, creating hybrids and trying to eliminate as many green house gases as we can is a great place to start.

Challenge 001

To start off, I think that Ray Kurzweil is a great speaker and tries to be somewhat inspirational which is what this generation needs. In my opinion, I think that the biggest debatable idea with all types of topics likes these is the ethics behind this. You will always get people that say yes and no. To me, the only thing that really matters is what the government has to say about it because if they say no, then its not happening; end of story. If they say yes, then ethic conversations will be held.

My problem with most of these videos is how they all say that they "have the tools." I think its great what they are doing, dont get me wrong, but I want to see it work. I want to see proof that they have created something to overcome disease and poverty. The idea is great, but I want to see it happen. I also think it is great about how he talks about how people see technology in the future as linear when it was really exponential. I personally didnt think about how technology will be absolutely vital in the future. Ray talked about analyzing the sequence of HIV. He then continues to talk about how they MAY be able to overcome all these problems.

I think what these scientists are doing is great, I just want to see it happen. I want to be able to complete a 15 minute olympic sprint without taking a breathe and want to sit in the bottom of a pool for four hours.

Wednesday, September 28, 2011

Challenge 014

This is happening to you because you are only declaring n as a double data type. While n = 99/100, these values are not double data types. Therefore, the compiler is outputting an integer and not a double. You either need to declare both values as double by naming them or you need to make those two value double data types by adding .0 after each of them.


One solution to this problem is to put .0 after each of the values because that turns it into a double data type.

double n = 99.0/100.0;

This is telling the compiler that this is a double data type which will eventually lead to the output of a double.



Another solution that would work would be to name each of the values. I used x and y. This is useful because you can then declare each of the values separately as a double data type instead of the whole quantity, n. You then need to tell the compiler to output the quantity (x/y). Since these two values were declared double, they will output a double data type of 0.99.

double x = 99; double y = 100; System.out.println(x/y);

Tuesday, September 27, 2011

Challenge 009

First I had to research Boolean Variables. I found out that either x or y have to be true and their conjugate has to be opposite.

If x were true and y were false, then it would fit all three expressions.

For the first expression, both sets must be true because of the && symbols. this works because x is true in the first statement and y is true in the second set because ! means not so not false will make it true

For the second expression, both sets must be true again and that is the case because x is true in the first set and the second set is true because !(x && y) means (!x || !y) and !y is true.

For the third expression, either the first or the second set must be true and that is the cause because x is true and !y is also true. These both need to be true due to the &&


Friday, September 9, 2011

Challenge 008

The output ends up to be -1.

We name the value "num"

The initial value starts out to be 5. int num = 5;

The while loop tells us that the value will decrease by an interval of 2 and that the loop will continue to do so until the value turns out to be less than 0.
The next line tells us that the interval is to decrease by -2 num -= 2;

This tells us that the value most be -1 because it cannot pass -2 and the value has to be less than 0.

Challenge 010

TThe output turns out to be 2.0 .

the initial value for m is 4 and n is 5 int m = 4, n = 5;

We then add m and n so 4+5. double d = Math.sqrt((m + n) / 2);
Then we divide by 2 and take the square root.
The answer is then rounded to the nearest whole number because of double. Double is a type of data. A double Data type can hold a floating-point real number. It can only hold several decimal points. Because the int is before the m and the n, when you take 4+5 to get 9 and divide by 2, you end up with 4.5 but only take the integer which is 4. The square root of 4 is 2 and because the code is calling for a double data type, it adds a decimal value which in this case is 0. For example:

If you take the square of 4.5, it will kick out 2.0. If you take the square root of 9.123412345, it will kick out 3. If you plug in 9.999999999999, it will kick out 3.0.
However, as soon as you take a square root of an integer that is not a perfect square, it will give you the decimal value for example, sqrt of 10 is 3.162277... and when it is output from the compiler, it is also 3.162277...

= 4+5=9. 9/2= 4.5 but you only take the int. SO...: sqrt of 4= 2. and because it is double. you get 2.0!!!

THIS BETTER BE CREDITED!!!!!

Challenge 007: 9/11 Conspiracy?

Since it's coming up and is such a good debate topic, I want to post a video about the 9/11 conspiracy that so many people swear by.



The music is annoying in the background but you still get good audio of what the people are saying. So watch this short clip and then respond to the topic listed below. Also feel free to come up with your own questions or just say what's on your mind.

  1. Is the U.S. government to blame for the attack on the WTC?
  2. Do you believe that there were bombs planted in the bottom of the towers?
  3. What do you think about people calling out our government and saying it was our fault that this occurred?
So you guys don't take this the wrong way, I think this video is complete garbage!

Monday, September 5, 2011

Challege 002 Synthetic Life

Creating a synthetic Cell will without a doubt change our biologic lives as we know them. To transplant chromosomes and sequences of DNA, it not only takes great intelligence, but also creativity. From the sounds of it, it is an extremely lengthy process that has no room for the slightest error. Craig Venter and his team had one error out of over a million base pairs and that set them back three months in order to analyze and correct their mistakes. They used technology by using a debugging software to find the error and to repair the sequence. In order to have the patience and design to work on a sequence for 15 years is incredible. I also find it interesting and unique to embed watermarks within the sequence of code in order to establish that someone has demonstrated the code correctly. They implemented an e-mail address in that someone can send a message to if they have written the code correctly. I think that this is definitely helpful because it tells the person that they are on the right track. One of the quotes, "See things not as they are, but what they might be," tells me, personally, that someone should not simply demonstrate mastery on a specific topic by completing it based of off fact, but to come up with your own way to reach the end of that topic. This all leads back to the idea that creativity will get you further than one may realize. To perform a task off of facts is not as important as performing a task based off of one's personal (creative) understanding on a topic.

From an ethical standpoint, I think that it is still up for debate: Rather creating life synthetically is ethical, is up to the people to decide. I dont think that the white house should classify ideas like this, but I do think that they should determine wether it is ethical or not. But do I think that it is ethical to substantially decrease the time to create a vaccine for a deadly disease? Yes, but there are also other things to look at, so I think this topic can go either way, depending on how you look at it.

I have to imagine that if we are able to transplant DNA and chromosomes, this will open up new ideas in the future. If I had the technology, materials, and intelligence, this is would i would do with my knowledge:
When a baby duplicates chromosome 21 for a total of 47 instead of 46, it results in down syndrome. Now again, I dont know if any of this is possible or has been done already, but i would try to transplant a normal pair of chromosome 21 with the abnormal (down syndrome) set of chromosome 21. If this is possible to do, I would assume that this will result in a cure for down syndrome. If this is possible to do, it would leave me to assume that other DNA abnormalities can also be cured.