L05-ConsoleIO1 - King Fahd University of Petroleum Minerals...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
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
Image of page 4
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
Image of page 5

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

View Full Document Right Arrow Icon
Console Input
Image of page 6
Details ..
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '08
  • ZAMAN
  • Saudi Arabia, King Fahd University of Petroleum and Minerals, Fahd of Saudi Arabia, King Fahd University of Petroleum & Minerals College of Computer Science & Engineering

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern