The math class will be a very important part of our final program. The math class has various math related functions that can help us. There are functions that can compute the sin, cos, and tan of an angle. In our physics program these can be used to find the direction of vectors and the magnitude of their components. The class also contains functions that compute the square roots and exponents. These would be important because a lot of physics problems contain exponents and square roots. The class contains different functions for rounding which would allow the user to choose what place to round the answer to. The picture shows a simple code that computes the value of the square root of 4. The math class will be very helpful in creating our final program.
Monday, April 11, 2016
Thursday, March 31, 2016
Physics!!!
Everybody loves when someone else can do a physics problem for them.
That's why we've been hard at work creating a program that incorporates
every single physics equation, complete with the ability to solve for
any variable. Through the use of many conditional statements, switches,
and what will be hundreds of line of code, we hope to bring forth
something that can help you finish your physics homework in 60 seconds
or less!
This just might be our final product down the line, but we are not sure at this point if such a feat is possible. However, that's exactly what we set out to do, create something we never thought we could do.
This just might be our final product down the line, but we are not sure at this point if such a feat is possible. However, that's exactly what we set out to do, create something we never thought we could do.
Monday, March 28, 2016
Classes
Classes are the basis for object oriented programming. This week we learne
d how to create classes and objects to improve our code. The class is like a blueprint, it describes the object and how it will function. The object is the actual interpretation of the class. Objects can come from the same class, but have different features. This is like how a builder can make houses with the same blueprints but they can have different colored doors and slightly different layouts. Methods define the behavior of the class. Methods can be thought of as verbs while the object is the noun that does the action. Methods and variables in classes can be defined as public or private. Public variables and methods can be accessed from anywhere while private methods can only be accessed from within the class. Creating private methods allow the programmer to restrict access to certain features of their code which can help to stop bugs.
d how to create classes and objects to improve our code. The class is like a blueprint, it describes the object and how it will function. The object is the actual interpretation of the class. Objects can come from the same class, but have different features. This is like how a builder can make houses with the same blueprints but they can have different colored doors and slightly different layouts. Methods define the behavior of the class. Methods can be thought of as verbs while the object is the noun that does the action. Methods and variables in classes can be defined as public or private. Public variables and methods can be accessed from anywhere while private methods can only be accessed from within the class. Creating private methods allow the programmer to restrict access to certain features of their code which can help to stop bugs.
Monday, March 14, 2016
Encapsulation
This week, we finally learned how to keep the NSA's prying eyes from our precious program data, with the use of the Encapsulation method. This coding technique virtually "encapsulates" the data you choose, as to prevent other parts of a program, or even the outside world, from accessing and changing the data.
This can be useful for keeping certain data types constant, while allowing certain subsets within it to be changed. The same can be done with "viewing rights," as you can designate which class and objects can be seen or not seen by the public. In the example below, the data class "myAccount" is visible to the public, as well as the account # associated with it. If set to "private" instead, only the class will be visible, not the #. This has many real world applications, especially in the financial industry.
Monday, March 7, 2016
Functions and Loops
This week we learned about the creations of functions and loops. A function is a piece of code that performs a certain task. The function can be called several times throughout the program without having to rewrite the code each time. This makes coding faster and easier. Functions can be defined to take in values or use predefined values. A function has a certain return type that must be returned at the end of the function. Functions can be defined for several different uses such as computing an average or printing out a message. The use of functions will be very important in our final project. Loops are used to repeat the same few lines of code several times in a row. There are two main types of loops, the while loop and the for loop. The while loop is less rigid than the for loop. In a while loop, a statement is made that is either true or false. The code inside the loop keeps being repeated until the statement is false. This type of loop allows the programmer to change how many times the loop runs based on input from the user. In a for loop the number of times the code will run is more defined. The programmer must choose a variable, a statement, and a way to change the variable. The variable is changed in the same way every time the code runs. This allows for less change in the way the loop will run. The picture shows a for loop that is used to print out the phrase four times in a row.
Sunday, February 28, 2016
Getting There...
Things have gotten even more complicated with the arrival of arrays, one-dimensional, two-dimensional, and three-dimensional. Arrays are basically data tables that a program can pull from to perform certain tasks and algorithms. There are two main ways to place values into an array: a) through the use of a "cin" command, or b) by stating them when you initially declare the array. The included screenshot displays the second method, and uses chosen data values to complete a simple subtraction and output function. Arrays will be a key part of our final program.
Monday, February 22, 2016
Learning More of the Basics
This week we have been learning more of the complexities of C++. We have been learning more about different data types and what they are used for. We learned that the primitive data types are char, int, double, float, and bool. These are the most simple data types and are easiest to use. Int stores an integer; double and float store rational numbers; char stores characters; and bool stores a true or a false. Along with the primitive data types we learned about the if statement. The if statement allows you to check if a statement is true or false. If the statement is true, the code will execute; if the statement is false, the code will not be executed. This allows the computer program to make decisions based on the information that is passed to it. This can also be used to stop errors from occurring such as before dividing checking to see if the denominator is zero. Using the primitive data types and if statements, we have been able to make slightly more complicated programs.
Subscribe to:
Comments (Atom)







