Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Season6Test1v1Task1 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int tries = 0;
- while(true){
- boolean validInput1 = false;
- boolean validInput2 = false;
- System.out.println("enter cards");
- char firstCard = sc.next().charAt(0);
- char secondCard = sc.next().charAt(0);
- if((firstCard>'2'&&firstCard<'9')|| firstCard=='T'||firstCard=='J'||firstCard=='Q'||firstCard=='K'||firstCard=='A'){
- validInput1 = true;
- }
- if((secondCard>'2'&&secondCard<'9')|| secondCard!='T'&&secondCard=='J'||secondCard=='Q'||secondCard=='K'||secondCard=='A'){
- validInput2 = true;
- }
- if(!(validInput1&&validInput2)){
- System.out.println("Invalid input!");
- }
- if(firstCard=='A'&&secondCard=='A'){
- System.out.println("Two aces! Number of tries: "+tries);
- break;
- }
- else{
- tries++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment