Let’s think a little bit about what type would be most appropriate for the following variables:
Name
Height
IsSleeping
HoursSinceAte
IsHappy
HappinessAmount
AngryAmount
MyCat
That last one is a little tricky isn’t it? After all, a cat is not a number, a string, or a bool. It’s something more complex.
Later on in this course, we’ll introduce you to ‘classes’, which are used for more complex ‘object’ data types, like cats, cars, people, and other types of objects.
Declaring Variables review:
Remember, when you declare a variable, it always comes in this form:
type name = initialValue;
example:
Try It Now: Expanding our Hello World Program
Let’s get a little more practice with using variables in a real application.
This program is a little longer! But if you read it carefully, you should be able to understand it.
Pay attention to the comments for details!