Elite Coders Society
Hello Guest!
Join us here in this forum!
Please Log in or Register to access more feature in this site.
Start Learning!

† Copyright ©️ 2011 - EliteCoders.forums.ag †


Start sharing and learning new skills about programming and design by building connections with other professional and students.
 
HomeForumPortalCalendarGallerySearchRegisterLog in
Elite Coders Partner Links

EliteCoders™️ News!
Hello Guest!, Welcome in our forum. Be active!

Share | 
 

 Buffered Reader Syntax

View previous topic View next topic Go down 
AuthorMessage
avatar
Admin[dElmARk]
Forum Owner
Forum Owner

Posts : 78
EC-Points : 6304
Thanked : 21
Join date : 15/10/2011
Age : 22
Location : Philippines

Hacker's Info
Hacking Exp:
0/0  (0/0)
Hacker Type: White Hat
Hacking Title:

PostSubject: Buffered Reader Syntax   Sun Oct 16, 2011 4:35 am

Buffered Reader Syntax

Code:

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

Program Sample:


import java.io.*;
class Pname{
public static void main(String [] args)throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("[Message]");
String Svar = br.readLine();
System.out.println("[Message]");
}
}


______________
Note:
If you put "String Svar = br.readLine();" it means that you are declaring the variable when you input the content.

______________________________________

Back to top Go down
View user profile
avatar
Admin[dElmARk]
Forum Owner
Forum Owner

Posts : 78
EC-Points : 6304
Thanked : 21
Join date : 15/10/2011
Age : 22
Location : Philippines

Hacker's Info
Hacking Exp:
0/0  (0/0)
Hacker Type: White Hat
Hacking Title:

PostSubject: Re: Buffered Reader Syntax   Sun Oct 16, 2011 4:08 pm

Activity BufferedReader.


Create a program where the computer will interact with the user.
Ask for the following.
(a) The full name of the user.
Computer’s reply: How are you (name of the user).
(b) The favorite food of the user.
Computer’s reply: We have the same favorite….
(c) The favorite movie of the user.
Computer’s reply: I don’t like that.
__________


Program Code:

import java.io.*;
class Activity{
public static void main(String [] args)throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("What is your name: ");
String Name"How are you " + Name);
System.out.print("What is your favorite food: ");
String FavFood =br .readLine();
System.out.println("We have the same favorite, " + FavFood);
System.out.print("What is your favorite movie: ");
String FavMovie = br .readLine();
System.out.println("I don't like that, " + FavMovie);

}
}




Sample Output:


What is your name: User
How are you User
What is your favorite food: Rice
We have the same favorite, Rice
What is your favorite movie: Iron Man
I don’t like that, Iron Man


______________________________________

Back to top Go down
View user profile
 

Buffered Reader Syntax

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Elite Coders Society :: Lobby/Social :: Basket-

Protected by Copyscape Duplicate Content Finder
Powered By EliteCoders™

Elite Coders Partner Links
GreyPhantomYour Link HereYour Link HereYour Link Here
Yahoo!GoogleFacebookForumotion