HOW TO DO

HOW TO DO - Lecture material and files on how to use UNIX

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

View Full Document Right Arrow Icon
------------------------------------------------------------------- HOW TO DO "USER INPUT" IN JAVA ------------------------------------------------------------------- A program sometimes needs to ask the user for information, e.g. needs to find out the user's name, or age, etc. Java has some input-output functions built into it. If you are doing your Java programming on rohan, then you can instead use rohan's input-output Java functions, which are easy to use. ------------------------------------------------------------------- EXAMPLE OF SDSU.IO ================== import sdsu.io.*; public class Prog1 { public static void main(String args[]) { String s; int n; double x; s = Console.readLine("Enter your name: "); n = Console.readInt("Enter your age: "); x = Console.readDouble("Enter a real number: "); System.out.println("Your name is " + s); System.out.println("Your age is " + n); System.out.println("Your real number is " + x); } } ------------------------------------------------------------------- A WARNING ABOUT SDSU.IO:
Background image of page 1

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

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

Page1 / 3

HOW TO DO - Lecture material and files on how to use UNIX

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

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