Wednesday, October 31, 2007

Today in class, I took a test on BOOleans.

Friday, October 26, 2007

Provide yourself an example (not one from your instructor) of how you use a particular command that
will help jog your memory in the future when you need that command again. You must provide a little
code as well as a written explanation with this one.

In order to switch two values, there needs to be an additional new variable that is assigned the value of one of the things to be switched up. The following, for example, will not process the right way:

//to switch the two up:
int a = int b;
int b = int a;
// this would give them bot the value of b

To do the right switching up, this has to be done:

int x = int a;
int a = int b;
int b = int x;
// this would work correctly.
It is important to know how this works as such things might be used in many applications. One can use it, for instance, for alphabetizing.
[Ms. Petr, I did this at home because I forgot to do it in class.]

Thursday, October 25, 2007

Are there any specific tips you would give to someone else tackling the same problem? How would what you suggest benefit that person in solving the problem?

Comparing Strings, as they are not like primitives, could be perplexing to some people. It is not right to use the <, or >, or any other similar signs when comparing Strings. We rather uses the .compareTo() or the .equals() techniques. These techniques help us compare two strings as follows:
1. the .equals() techniques checks to see if two strings are the same, and
2. the .compareTo() technique gives numeric values (negative, positive, or zero) after checking if two Strings are equal.
When comparing Strings, we use such methods rather than the familiar mathematical signs. I believe these techniques help programmers avoid errors and problems to a certain extent.

Wednesday, October 24, 2007

How did you go about testing your program? What were the results of that testing?

Today I worked on writing a code that would give a numeric grade for a letter grade given by the user. I needed to use the String method for this as I ask the user to give me a letter grade. When the user gives the letter "A" for instance, the program is to respond as "4.0." I need to use the String method to store the A value. But the problem comes when the user inserts either an "A+" or an "A-". My program is to recognize when there is a + or - next to the letter and add or subtract .3 from the normal value. When checking for that, I primarily used something like this:
String a == String ToBeChecked;
This does not work with strings as they are not primitives. So there was an error on my program. It should be fixed like this:
String a = equals(ToBeChecked);


Tuesday, October 23, 2007

What progress did you make today on your solution? What needs to be completed next class?

Today, I worked more on getting information from the user and using the input from the user to get something important done. I imported java.util.* and used the Scanner method to get input. I made a Check Mail Class that checks to see if a package is acceptable. I used if, else if, and else in my class. I also learned that a variable cannot be defined inside an if, else if, or else. Next class I plan to master these methods and getting input from the user.

Sunday, October 21, 2007

Scored through 10/18. Check Edline for scores on Monday evening.

Thursday, October 18, 2007

What problems did you encounter while developing your solution? How do you plan to overcome them?/How did you overcome them?

Today I developed a Grocery List program that allows people to enter item prices and gives them the final total result. I used the printf method to print the Dollar sign and to limit the number of digits to two. I realized that to assign a value to a double primitive you use f instead of d (when using printf). And to signify integer, you use d. That resulted in an error, but I was able to see in and fix it.

Tuesday, October 16, 2007

What choices did you face in developing your solution, and how did you choose among them?

Today, I learned howto get input from the user in java. I also learned about the if, else if, and else decision structures. The way we use these structures may affect the way our program is going to turn out. if is used when there is a specification for the result expected. else if is used to do the same thing, but it avoids any specifications made previously, and else is used to include everything except things mentioned above. Look ate the following example for reference:

import javax.swing.*;
public class InputPractice {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int x;
String s;
s = JOptionPane.showInputDialog("What did you get on your test?");
x = Integer.valueOf(s);
if (x >= 90)
{
System.out.println("That's an A! You did an Excellent job!");
}
else if (x >= 85)
{
System.out.println("That's a high B! Very Good job!");
}
else if (x >= 85)
{
System.out.println("That's a B! Good job!");
}
else if (x >= 70)
{
System.out.println("That's a C! That is an OK score. Try to do better next time.");
}
else
{
System.out.println("You should study much harder next time.");
}
}
}


The places where else, else if, and if were used should be chosen wisely.

Monday, October 15, 2007

What progress did you make today on your solution? What needs to be completed next class?

Today, I learned about another primitive type in java: Boolean. This is a primitive that returns only two results: true or false. This is a very important part of java. I learned about operators very important in java like !=, ==, !, , and others. These are very important operators. I plan to excell in these operators next class.

Wednesday, October 10, 2007

What problems did you encounter while developing your solution? How do you plan to overcome them?/How did you overcome them?

When I ran my driver classes for the classes I wrote, I saw that there were problems with the interaction between the two classes. Sometimes, the problems were errors in the codes written. Other times, they were problems that had to do with the compiler (i.e. I wrote them they way I thought they should be, but the compiler interpreted them differently). Whenever I had such problems, I went back and analyzed the specific places where there were problems and tried to fix them. When I was stack, I asked my teacher. I finally had all my classes working just fine.

Tuesday, October 9, 2007

Provide yourself an example (not one from your instructor) of how you use a particular command that will help jog your memory in the future when you need that command again. You must provide a little code as well as a written explanation with this one.

The equal sign in Java is used for assignments. It is really crucial to know the difference between the = sign in Mathematics and Java. In Math, the two things that are set equal have exactly the same value and no assignment is done. However, in Java, the entity to the right of the = sign is assigned to the entity on the left side.
Example:

public SimpleCalculator(double x, double y)
{
sumTotal = x;
productTotal = y;
}

//is very different from:

public SimpleCalculator(double x, double y)
{
x = sumTotal;
y = productTotal;
}


On the first one, the x and y values are assigned to the sumTotal and productTotal values. But in the second one, the reverse is done. So it is very important to know the real meaning of the "assigner" in Java.

Monday, October 8, 2007

What progress did you make today on your solution? What needs to be completed next class?

Today, I worked more on writing classes. I wrote a class for determining Roach population and another class that is a simple calculator. It was really interesting and I believe that I am getting much better at writing classes. Next class, I plan to write more classes and their testers so I could be very good at writing classes.

Sunday, October 7, 2007

Scored through 10/5. Check edline on Monday evening for grade.

Friday, October 5, 2007

Are there any specific tips you would give to someone else tackling the same problem? How would
what you suggest benefit that person in solving the problem?

I worked on creating more classes today. I learned that when ever you use a method in a testing program, you should never forget the parenthesis that come after it. I learned this when I tried running a program and I found out that there was an error, which was an absence of the () after the method I was referring to.
Example:

System.out.println("The perimeter of rectA is: " + rectA.getPerimeter());

The () after the getPerimeter method are very crucial in this code.

Thursday, October 4, 2007

Provide yourself an example (not one from your instructor) of how you use a particular command that
will help jog your memory in the future when you need that command again. You must provide a little
code as well as a written explanation with this one.

Look at the following code:

public Rectangle(double x, double y, double width, double height) //creating the edges of the rectangle
{
myX = x;
myY = y;
myWidth = width;
myHeight=height;
}
// now the methods
public double getPerimeter()
{
double perimeter;
return perimeter = myWidth + myWidth + myHeight + myHeight;
}


Here myWidth has to be used when calculating the perimeter instead of width because width is an unspecified variable. This code, for example, would not work:
...
return perimeter = width + width + height + height;

Wednesday, October 3, 2007

How did you go about testing your program? What were the results of that testing?

Today I finished my MPG assignment, which was a program that needed two classes. It was very interesting, but also challenging. After I finished the first class, I made another class to see if my first class works properly. When I ran the testing class, I turned out to be queer, which meant that my first class had errors in it. Thus, I went back and looked at the problems, which were hard to identify, and solve. Finally, after making all the solutions to my first class, I went back to the testing class and ran it. It worked this time. Mission Accomplished.

Tuesday, October 2, 2007

What problems did you encounter while developing your solution? How do you plan to overcome them?

Today, I worked on developing a class as a basis for another class. Developing this class was different from anything I did before, and so it was difficult. I did not know what exactly to do and how to use the methods properly. I used the program I made yesterday(Bank Account) to help me. With more practice I will hopefully be better at this.

Monday, October 1, 2007

What progress did you make today on your solution? What needs to be completed next class?

Today in class, I learned how to carefully design the classes I need before any coding is done. I also learned about the importance of doing this. Unless, I have something primary to base my coding on, my programs are not going to be of any effect. These procedures seem to be intricate, and I am sure I need to look at them very closely before fully understanding everything that is going on. We started the lesson by making a code that takes care of a person's bank account. This afternoon and tomorrow, I plan to study these methods and master them before I learn something new.