2 store values

how to store number and text values

program requirements

store values like 123456 and "Hello" and display them together in a short message.


remember variables can store values
a String variable can store text
an int variable can store a non-decimal number
a variable must be declared before it is used.

reuse the code

1 int days = 31;
2 String monthName = "January";
3 System.out.println("There are " + days + " days in the month of " + monthName);
understanding the code
lines 1 and 2 declare and assign values to the variables
lines 3 displays the values stored in the variables
The code above will produce this output in the console
There are 31 days in the month of January
understanding the output
The value stored in the variables is displayed along with text values to create a short message.

develop the code

A program to display weather information including text and number values stored by the program.
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 humidity is 93% and the visibility is good
The pressure is 983 mb and the chance of rain is high
coding frame
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
) instead.