2 store values

how to store numbers

program requirements

store values like 123456
we will find out later about numbers with fractions (eg 123.45)

learning-point

a number value like 123456 is an integer (int), there is no decimal point.
a variable to store an integer value is declared as an int data type

introducing the code

1 int hours = 24;
2 System.out.println("The number of hours in a day is : " + hours);
understanding the code
on line 1 the hours variable is declared as int because it will store a non-decimal number (integer).
on line 1 the variable called hours is also assigned the initial number value of 12
on line 2 the value stored in the variable hours is displayed
The code above will produce this output in the console
The number of hours in a day is : 24
understanding the output
The value stored in the variable is displayed.
The name of the variable is not displayed, it does not output: hours

develop the code

a program to store the temperature and wind speed, then display output using the stored values
read the user interface design below
read the code in the code frame, run the code
edit the code to complete part 2B, use part 2A to help, there are //comments in the coding frame to help you

user interface design

the final display should look like this
The temparature today is 14
The wind speed today is 11
coding frame
Loading…
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.