Monday, March 31, 2014

Class of March 31, 2014

     Common reasons for open to fail include: that the file might not exist or that the name that was typed is written incorrectly. To catch errors we use member function fail. Fail will return a bool value and if this value is true, the stream operation failed. The function exit, halts a program which is what is best to do when a stream open function fails.

Friday, March 28, 2014

Class of March 28, 2014

     In today's class we begun chapter 6. It is about I/O streams. I/O refers to program input and output. Files for I/O are the same type of files used to store programs. As programmers, we should use files because they allow us to store data permanently which means that we do not have to input the same things every time we run the program and it makes life a whole lot easier and saves us time if the program requires a lot of input.

Defining input-file and output-file streams:
     #include <fstream>
     using namespace std;

Declaring input-file stream:
     ifstream     in_stream;

Declaring output-file streams:
     ofstream    out_stream;


Wednesday, March 26, 2014

Class of March 26, 2014

     Today the professor took some time to clear our doubts regarding the lab assignment. I am nervous because even though I already finished the first 4 problems, I have yet to start problem number 5. I think I am in denial because it looks really hard and long. Regardless, I have done pretty well in all labs therefore I am going to spend all these next days doing the fifth problem and hope for the best.

Monday, March 24, 2014

Testing! Class of March 24, 2014

In today's class I learned different types of testing like: unit, integration, and system. Unit testing tests individual parts. Integration testing joins all the programs you unit tested to see if they work. System testing tests correctness and that system runs correctly. An important rule for testing to remember is that the programmer needs to "test every function in a program in which every other function in that program has already been fully tested and debugged".

Friday, March 21, 2014

Class of March 21, 2014

In today's class we discussed preconditions and postconditions. A precondition states what is assumed to be true when the function is called. A postcondition describes the effect of the function call.

for example:

void swap_values (int&n1, int&n2);
//Precondition: n1 and n2 have been given values
//Postcondition: the values of n1 and n2 have been interchanged

Preconditions and postconditions are helpful because:
1. they specify what a function should do
2. they minimize design errors and time wasted writing code that does not match the task at hand

Wednesday, March 19, 2014

Class of March 19, 2014

     In today's lecture, the professor discussed: void functions and call-by-reference parameters. Void functions do not return a value. I remember that I used void functions for one the labs, the problem that outputs the horoscopes. Call-by-reference parameters allow us to change the variable used in the function call. Call-by-reference parameters are useful but the programmer has to be careful when he or she uses them.

Monday, March 17, 2014

Class of March 17, 2014

     In today's lecture we covered: local variables, global constants, and global variables. Global constants are very good and helpful but global variables should be avoided because they make the program hard to understand.

Friday, March 14, 2014

Labs, again...

     I was able to finish and submit lab 4 by today. I had to rewrite the problem about the "99 bottles of beer…" because of some missing curly braces. After working with it for like 4 hours, until I believed it was perfect, I completed it and it feels good! 3 more labs to go… :-)

Wednesday, March 12, 2014

Lab 4

     My lab 4 is in progress. I like to take at least one week to do each lab just so that I have enough time to ask the professor any questions that will clarify doubts and that way not feel rushed or like I am doing a bad job. I've realized that I do not like the problems that have anything to do with interest rate. I don't know why, but I just do not like them.

Monday, March 10, 2014

Functions!

     Functions are very useful in programming. I've already used programmer-defined functions in lab 3 and I'm pretty sure I'll have to use them in the next labs that come.

The Function Declaration:
ex:

int result (int x, int y);
//Adds x and y and outputs the result.

The Function Call:
ex:
   
sum = result ( x , y );

The Function Definition:
ex:

int result (int x, int y)
{
int sum;

sum = x + y;
return (sum);
}

Friday, March 7, 2014

Class of March 7, 2014

     On today's lecture, the professor discussed predefined functions like: abs(x) which computes the absolute value of a variable and fabs(x) which also computes the absolute value but in this case it is of a type double variable. We also discussed type casting but the professor told us it was not a good idea to use this in programs.

Wednesday, March 5, 2014

Midterm #1

       Today we took our first midterm. Although I studied, I am not feeling too confident about my grade. The first part, program comprehension, was tough and I doubt I did it correctly. I simply hope to pass this test and do better on the next one.

Monday, March 3, 2014

Class March 3, 2014

    Today during class we reviewed for the test and I am feeling confident. I practiced with it by myself and was able to do it correctly and then run the programs in the compiler to check if my answers were correct. I also reviewed with the chapter slides. I hope it all goes well on the test...