Wednesday, August 31, 2011

8/31!!

So I took my laptop in, as I thought it wasn't anything I could fix...the LCD was, for lack of a better word, broken. The other issue that was wrong with it is that when you started up the computer it would cycle between the gateway screen and a courser, their looking looking into what is causing this, they think it may be something to do with the hard drive. I originally thought it may have something to do with the bios...

As for the summer, I didnt do much with programming; I did finally install a sound card in my desktop as well as get a second monitor...which is something I've been wanting to do for awhile now. I 'll upload a picture(maybe) sometime.

Friday, August 26, 2011

8/26!!!

Its been awhile....
My laptop took a dive into the floor, I took it apart to see if anything hardware related was broken, or I could fix, but it doesn't look like it so im taking it into a tech shop Monday.

Class is starting in about 5 weeks...I got my schedule a few days ago. I have Web technologies, Programming 2 and Intercultural Communications. Its rather different than last semester, where I had 2 Business classes on campus and one IT class online.

I'm looking forward to this semester since I have all 3 classes on Campus, one im pretty sure will be taught by a instrucer I've had before(Richard Cummings) and one which is a pre-req to psychology classes, which I would consider something of a minor...but we dont have established minors at MSB.

Tuesday, June 21, 2011

June 21

Been very  busy between research papers and presentations I had to make for school, I'll get a post on what ive been doing late this week or early next week.

Tuesday, June 7, 2011

We have been discussing arrays in the past week.
Our assignment was to create a program that took the first and last name of the user and output it in reverse order.



 
   

   
    cout << "please enter your first name: " << endl;
    char str1[30];
    cin >> str1;
   
   
    cout << "please enter your last name: " << endl;
    char str2[20];
    cin >> str2;
   
   
    cout << "Your name before manipulation: " << str1 << " " << str2 << endl;
   
   
    cout << "your name after: " << str2;
    strcpy(str2, str1);
    cout << " " << str2 << endl;
   
   
comments:
I could have eliminated 2 separate lines for the cin input, and just did,
cin >> str1 >> str2
char str1[30];
char str2[25];

or something close to that.
I also feel it kind of redundant the way we have to reverse order.
Cout str2 and then copy the value of str1 into str2 and output it again.
A better way I think is we could just cout >> str2 >> str1
This eliminates extra code, along with if you have to use str2 again latter on the in the program you can use it as the "real" value of str2
   
   
   
   
 

Wednesday, June 1, 2011

June 1!!!

We user defined simple data and string types(last week) this week we are working with arrays.

In Chapter 8, there is a discussion of the "Rock, Paper, Scissors" game. Discuss how this game works, and how a C++ program that models this game will use a variety of types.

(may have done this wrong)

First it defines the object rock, paper, and scissor.
After that the function prototypes are defined.

Displayrules are called upon entering the game and display the Cout statements on page 446. 

Objecttype gets the keystroke that the user entered through a switch structure. It uses both uppercase and lowercase to decide. To passes the object that was selected to gameresults.

Gameresults, this calls winningobject to decide how the game should go; or, the truth table for the game.

After the truth table is found, it proceeds through game results first to see if the game is a tie, then it outputs each player’s choice. It then compares each player’s objects that they chose to the winningobject, via the convertenum function, and outputs the winner.

The convert enum function converts each of the enum defined(rock, paper, scissors) to something that can be recognized by C++(a cout statement)

Display results outputs the number of games played and who many times each player has won a game, the wins for player one is stored in wCount1 and the wins for player 2 is stored in wCount2. The loop for incrementing each counting sequence is in the main body of the program.






comment by instructor: Great job in breaking this down here, with "enum" in this case, would this be a function? How would this be defined?




my response
If I understand your question correctly, no, the:
enum objectType {rock, paper, scissors}
is no a function.

enum does nothing more than create a user defined data type.
So instead of
char rock, paper, scissors;
you have enum ObjecType {rock...ect

This is the reason you have to have a new function to "read" the data in the enum. Which is where the convert enum function comes into play(on page 449)

To define an enum data type use the following code:
enum TypeName {value1, value2, ect}

Monday, May 23, 2011

5/23

This unit expanded on the various types of variables. Discuss the difference and usage of local variables, global variables, static variables and automatic variables. Post some snippets of code illustrating their use. 

Local variables : are used within a block such as 

int main()
{

int num = 20;
cout >> “please enter a number” >> endl;
cin << num << endl;
}

Or in a function (maybe)
Int number (int num)
{
Cin << num
}
This sets num to 20 for the main() function 
They cannot be used outside of their block they are initialized in.
We have used these in just about every program so far.
If we think of them as a tv show, they are characters that come in for one episode or the main theme of one episode.

Global variables: These are variables that are initialized before the main program body 
Example:

#include 
using namespace std;
int num = 20;
int main()
{
cout << num << endl;
This initializes num to 20 for the entire program.

To use the tv example, they are the main characters or main plot of the show
We have used them, not as much though

Static variables: These are almost the exact same thing as global variables, except you can declare them within a block by using:

Static datatype identifier
Or an example
Static int = 20;
Another thing to note is that as long as the program is “going”
A good example is X on page 392
Void test()
Static int x = 0;
X = X + 2;
Cout << “inside test x = “ << x << endl;
Inside test x = 2
Inside test x = 4
Inside test x = 6
Ecrt..
What this does is increase x by 2 each time it executes around .
We have not used these that I am aware of.


Automatic variables: The book describes these as pretty much the same as local variables. The only addition from local variables that is mentioned is that they are initialized to 0.
From other wibsites that I found they said that they are not normally used by “human” programmers but program generators

Wednesday, May 18, 2011

I think its 5/18...

Choose one of the many topics that we have discussed so far in this course. Selection structures, repetition structures, functions, I/O etc. What have you learned about these? Have there been any surprises?


Functions in C++ are a bit different than what I expected them to be. I assumed that they were saved in a different area and when you call them you have to add the path into that call.
The prototype deals with the situation quite nicely though. I understand many people’s concerns and confusion about having to declare the variables for that function so late in the program, or that it is considered good practice to put the functions after the program. I rather like it though, for myself it seems cluttered to have something opposed to the main function coming before it.

I feel I can do better on repetition structures, I never was good at them, have a hard time deciding what loop to use and how get the loop to do what I want it to do and how many times.




My midterm discussion board for programming 1

I've decided to post some things for my business classes as well, but only major project.


For business communications we are to do a 15-20 min presentation on a topic regarding communications, this is a 2 person assignment.


We have chosen social media as our topic, I dont have much more, we just got it 2 days ago.


There is not much for intro to business, unless I can find out how to upload to a pdf doc(our final project is a paper on a any topic(mine = what defines a good leader) that has to be 5-10 pages) I'll look into it. 




For my programming 1 class our project of the week is to create a program to count the number of vowels in a sentence using void function. I think I'm almost done with it but have 1 issue with the counting loop.