Barry Harris Dim6 Scale2
Barry Harris Dim6 Scale2
Barry Harris Dim6 Scale2
Give the text that is printed to the screen after each fragment of code is executed.
1.
String n1 = "56";
String n2 = "12";
String a = n1 + " - " + n2;
System.out.println(a);
________________________________
2.
int z = 2;
int m = 5;
z = z + m;
z = z + 1;
System.out.println(z);
____________________________
3.
int x = 2;
if (x >= 0)
{ System.out.println(“1”); }
else if (x == 2)
{ System.out.println(“2”); }
else
{ System.out.println(“3”); }
4.
int x = 4;
if (x < 2)
{ System.out.println(“1”); }
else if (x == 2)
{ System.out.println(“2”); }
else
{ System.out.println(“3”); }
5.
int z = 10;
for(int j = 1; j <= 4; j++)
{
z = z + 1;
}
System.out.println(z);
____________________________
6.
int z = 0;
for(int j = 1; j <= 2; j++)
{
for(int k = 1; k <= 3; k++)
{
z = z + 1;
}
}
System.out.println(z); ____________________________
NAME ________________ STUDENT NUMBER__________ LAB GP__________
However the messages should not be printed until all the temperatures have been
input. HINT: Build up the string to print in a variable as you process each input.