Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package app;
- //import java.util.Scanner;
- /**
- * Created by sorinapredut on 25/02/2019.
- */
- public class MyClass {
- public static void main(String[] arg) {
- //KeyboardInput in = new KeyboardInput();
- //Scanner in = new Scanner(System.in);
- char response, c, n1;
- boolean found;
- int n, i;
- int h = 0;
- char[] a = new char[20];
- do {
- //System.out.println("Input an integer between 1 and 20: ");
- //n = in.readInteger();
- //n=sc.nextInt();
- System.out.println(arg[0]);
- n = Integer.parseInt(arg[0]);
- break;
- } while (n < 1 || n > 20);
- System.out.println("input " + n + " character(s)");
- if (n > 1 && n < 20) {
- for (i = 0; i < n; i++)
- //a[i] = in.readCharacter();
- //a[i]=sc.next(".").charAt(0);
- a[i] = arg[i + 1].charAt(0);
- //n1 = in.readCharacter();
- do {
- //System.out.println("Input character to search for: ");
- //c = in.readCharacter();
- //c = sc.next(".").charAt(0);
- h++;
- System.out.println("numarul" + h);
- c = arg[n + 1].charAt(0);
- System.out.println("Input char to search for " + c);
- //n1 = in.readCharacter();
- found = false;
- for (i = 0; !found && i < n; i++)
- if (a[i] == c)
- found = true;
- if (found)
- System.out.println("character " + c + " appears at position " + i);
- else
- System.out.println("character " + c + " not appear in string");
- System.out.println("Search for another character?[y/n]: ");
- //response = in.readCharacter();
- //response = sc.next(".").charAt(0);
- response = arg[n + 2].charAt(0);
- //n1 = in.readCharacter();
- } while (((response == 'y') || (response == 'Y')) && (h != 3));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement