Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This program is for assignment #7 question #3
- import java.util.Scanner;
- public class ShowChar
- {
- public static void main(String [] args)
- {
- Scanner s = new Scanner(System.in);
- System.out.println("Please enter the String");
- String input =s.nextLine();
- System.out.println("Please enter the Character Position you would like to find from the string");
- int pos =s.nextInt();
- if (pos < 0 || pos > input.length)
- System.out.println("Wrong number");
- else if (pos != 0)
- {
- Char position = showChar(input,pos);
- System.out.println(position);
- }
- }
- public static Char showChar(String name,int place)
- {
- place--;
- char position = name.CharAt(place);
- return position;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement