L05-ConsoleIO1 - December 6, 2010 ICS102 Lecture5 : Screen...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: December 6, 2010 ICS102 Lecture5 : Screen Output and Console Input King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department System.out.println To write of the screen: System.out.println(Hello World"); It is possible to print more than one item: A plus sign is used to connect more than one item System.out.println("The answer is " + 42); Every invocation of println generates a new line after it finishes System.out.println(Hello World); System.out.println(Hello World); Package name Class name Method name The item to be printed on the screen Hello World Hello World println Versus print To stay on the same line, use print System.out.print(Hello World ); System.out.print(Hello World ); The print method is like println , except that it does not generate a new line With println , the next output goes on a new line With print , the next output goes on the same line Hello World Hello World Console Input What if we want to let the user choose the values he wants to use ? We can prompt the user by console )keyboard( input Console Input Import instruction Create Scanner object Read a first integer and assign it to variable a Read a second integer and assign it to variable b Console Input...
View Full Document

Page1 / 19

L05-ConsoleIO1 - December 6, 2010 ICS102 Lecture5 : Screen...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online