Preskoči na glavni sadržaj
Prijava
Sign up for FREE
arrow_back
Biblioteka

Scanner Methods Quiz

star
star
star
star
star
Posljednje ažuriranje about 2 years ago
5
1
Pitanje 1
1.

What is output by the code below?

Scanner s = new Scanner("1 2 3 4 5 6");

int x = 0;

x += s.nextInt();

x += s.nextInt();

System.out.println( x );

1
Pitanje 2
2.

What is output by the code below?

Scanner s = new Scanner("1 2 3 4 5 6");

int x = 0;

x += s.nextInt();

x += s.nextInt();

x += s.nextInt();

x += s.nextInt();

System.out.println( x );

1
1
1
Pitanje 3
3.

What is output by the code below?

Scanner s = new Scanner("1 2 3 4 5 6");

int x = 0;

while(s.hasNext())

{

x += s.nextInt();

}

System.out.println( x );

Pitanje 4
4.

What is output by the code below?

Scanner s = new Scanner("1 2 3 4 5 6");

int x = 0;

double z = 0;

while(s.hasNext())

{

x += s.nextInt();

z++;

}

System.out.println( x / z );

Pitanje 5
5.

What is output by the code below?

Scanner s = new Scanner("d 1 o 2 g 3 c 7 t");

int count = 0;

while(s.hasNext())

{

if (count % 2 == 1)

System.out.print(s.next() + " ");

else

s.next();

count++;

}