Guest User

Untitled

a guest
Jan 6th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Season6Test1v1Task1 {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Scanner sc = new Scanner(System.in);
  8.  
  9. int tries = 0;
  10.  
  11. while(true){
  12. boolean validInput1 = false;
  13. boolean validInput2 = false;
  14. System.out.println("enter cards");
  15. char firstCard = sc.next().charAt(0);
  16. char secondCard = sc.next().charAt(0);
  17.  
  18. if((firstCard>'2'&&firstCard<'9')|| firstCard=='T'||firstCard=='J'||firstCard=='Q'||firstCard=='K'||firstCard=='A'){
  19. validInput1 = true;
  20. }
  21.  
  22. if((secondCard>'2'&&secondCard<'9')|| secondCard!='T'&&secondCard=='J'||secondCard=='Q'||secondCard=='K'||secondCard=='A'){
  23. validInput2 = true;
  24. }
  25. if(!(validInput1&&validInput2)){
  26. System.out.println("Invalid input!");
  27. }
  28. if(firstCard=='A'&&secondCard=='A'){
  29. System.out.println("Two aces! Number of tries: "+tries);
  30. break;
  31. }
  32. else{
  33. tries++;
  34. }
  35. }
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment