1 display values

how to display data values

this tutorial shows how to display text and number values together and presents a simple programming task to complete

program requirements

code a simple program to output text and number values together
use this to display price information


text and number values can be output together
use + (plus sign), between each value to join them (concatenate)
remember text needs "speech marks", numbers do not
a space is often needed inside the speech marks to make gaps

introducing the code

here is the new code that will be featured
System.out.println("the 1st prime is " + 2);
understanding the code
The brackets contain a text value and a number value, there is a + symbol between the values
normally you would expect a + to mean add, as in 1+1 would result in 2.
since the first value is text, java read the + as join (concatenate)
The code above will produce this output in the console
the 1st prime is 2
The values are displayed as expected.

develop the code

read the user interface design
read the code, run the code, (coding frame)
edit the code to complete part 3B, use part 3A to help, there are //comments in the coding frame to help you

user interface design

the final display should look something like this
Welcome to the WaffleMaster!A triple chocolate waffle costs £7.55A Nutella sandwich waffle costs £7.75 and 1.25 for extra creamThe total for 3 Banoffee waffles at £7.75 each is £23.25
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.