Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class CharChecker {
- public static void main(String[] args)
- {
- Scanner in = new Scanner (System.in);
- String str;
- char ch;
- System.out.print("Enter a string: ");
- str = in.nextLine();
- System.out.print("Enter a character you want to check for: ");
- ch = in.next().charAt(0);
- if(str.indexOf(ch) == (-1))
- System.out.printf("The character '%c' doesn't appears in your string", ch);
- else
- System.out.printf("The character '%c' appears in your string", ch);
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement