Thread: help needed.
View Single Post
  #3 (permalink)  
Old 12-03-2007, 10:13 PM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,141
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.
Reply With Quote