dElmARk Admin
Posts : 92 Join date : 09/04/2012
| Subject: Introduction to Java Programming [Power Point] Sun Oct 21, 2012 5:31 pm | |
|
Introduction to Java Programming
Slide 34 Note: - Code:
-
import java.io.*; import java.util.*; class inputOutput{ public static void main(String []args){ BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); Scanner scnr = new Scanner(System.in); // String input System.out.print("What is your name: "); String name1 = br.readLine(); System.out.print("What is your name: "); String name2 = scnr.nextLine(); // Int input System.out.print("What is your age: "); int age1 = Integer.parseInt(br.readLine()); System.out.print("What is your age: "); int age2 = scnr.nextInt();
// double input System.out.print("What is your Grade: "); double grade1 = Double.parseDouble(System.in()); System.out.print("What is your Grade: "); double grade2 = scnr.nextDouble();
System.out.println("Buffered Reader inputs."); System.out.println("Your name is " + name1); System.out.println("Your age is " + age1); System.out.println("Your grade is " + grade1); System.out.println("\nScanner inputs"); System.out.println("Your name is " + name2); System.out.println("Your age is " + age2); System.out.println("Your grade is " + grade2); } }
| |
|