how to display combination of char and interger
Code :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tokens;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.Buffer;
import java.util.StringTokenizer;
/**
*
* @author Gottumukkala
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args)throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("enter name,house no.,street name,city name,post code:" );
String str=br.readLine();
StringTokenizer st= new StringTokenizer(str,",");
String s1=st.nextToken();
String s2=st.nextToken();
String s3=st.nextToken();
String s4=st.nextToken();
String s5=st.nextToken();
s1=s1.trim();
s2=s2.trim();
s3=s3.trim();
s4=s4.trim();
s5=s5.trim();
String name=s1;
int number=Integer.parseInt(s2);
String street=s3;
String city=s4;
int ps=Integer.parseInt(s5);
System.out.println("Name="+name);
System.out.println("House no.="+number);
System.out.println("Street name="+street);
System.out.println("city name="+city);
System.out.println("post code="+ps);
}
}
i need to display post code which is combination of string and integer.. for example post code is ST4 2EU
BUT i dont how to display it ... can please any one help me thank you friends
Re: how to display combination of char and interger
Re: how to display combination of char and interger
Why can't you store the post code as a String?
Take a look at this example:
Code :
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class UserInput {
public static void main(String[] args) {
try {
InputStreamReader is = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(is);
System.out.println("What is your post code?: ");
String s = br.readLine();
System.out.println("Your post code is: " + s);
}
catch (IOException e)
{
e.printStackTrace();
}
}
}