comp-prog/lecture_2_1
Matt Gottsacker
Marquette University High School
Last modified: 08.28.2019
So far, we have used Java to print things out. We have used it for some calculations, but nothing we can't do on a calculator. Now, we will start learning concepts that will enable us to formulate problems as programming problems.
"An algorithm describes how a problem is solved by listing the actions that need to be taken and the order of their execution."
It is a set of instructions to help plan a program.
It is a recipe.
int week = 1;
double profit = 736.0;
Java variables can be of the following types and sizes:
| type | size (bits) |
|---|---|
| byte | 8 |
| short | 16 |
| int | 32 |
| long | 64 |
| float | 32 |
| double | 64 |
Once it is declared, the value of a variable can change...
int week;
week = 1;
week = 2;
...unless it is a constant.
final int MAX_WEEKS = 5;
Constants also have different naming conventions.