Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-02-2007, 01:29 AM
Member
 
Join Date: Nov 2007
Posts: 33
dirtycash is on a distinguished road
help needed.
problem solved.

Last edited by dirtycash : 12-03-2007 at 11:15 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-03-2007, 09:05 PM
Member
 
Join Date: Nov 2007
Posts: 33
dirtycash is on a distinguished road
Code:
Scanner in=new Scanner(System.in); //scanner object to get input from keyboard later CODEpublic String getText(String prompt) { System.out.println(prompt); System.out.println("Enter word/email"); //make a string called b and in it put whatever the user inputs String b=in.nextLine(); return (b); } --------------------- CODEpublic int getNumber(String prompt) { System.out.println(prompt); System.out.println("Enter integEr"); int LOL=in.nextInt(); return (LOL); }
does this code answer the questions a and b properly?
it does compile but i dont think it works.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-03-2007, 10:13 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,022
hardwired is on a distinguished road
If you just want the two methods you can write and use them like this.
Code:
import java.io.*; public class ExpTest { Scanner in=new Scanner(System.in); public static void main(String[] args) { ExpTest test = new ExpTest(); System.out.println(test.getText("Enter word/email")); System.out.println(test.getNumber("Enter integEr")); } private String getText(String prompt) { System.out.println(prompt); //make a string called b and in it put whatever the user inputs // Save user input in variable "b" and return it to the caller. String b=in.nextLine(); return b; } private int getNumber(String prompt) { System.out.println(prompt); int LOL=in.nextInt(); return LOL; } }
If you want to encapsulate them in a separate class you would make a few changes.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-03-2007, 10:17 PM
Member
 
Join Date: Nov 2007
Posts: 33
dirtycash is on a distinguished road
problem solved.

Last edited by dirtycash : 12-03-2007 at 11:15 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help needed!!! :S mark-mlt Networking 1 04-14-2008 10:27 AM
Help needed. necro-1000 AWT / Swing 2 01-12-2008 12:37 PM
Help Needed pks New To Java 1 01-09-2008 01:07 AM
Uni Project - GUI - Help Needed deeadeed New To Java 0 12-04-2007 12:10 AM
jfreeReport help needed sandor XML 1 04-20-2007 09:10 PM


All times are GMT +3. The time now is 11:18 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org